Skip to content

Commit 291062b

Browse files
Merge pull request #319 from pusher/feature/114-document-client-events-in-readme
Document how to trigger client events in README.md
2 parents c384473 + 00cf245 commit 291062b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ What else would you want? Head over to one of our example apps:
5656
- [Callback parameters](#callback-parameters)
5757
- [Parsing event data](#parsing-event-data)
5858
- [Receiving errors](#receiving-errors)
59+
- [Triggering events](#triggering-events)
5960
- [Testing](#testing)
6061
- [Extensions](#extensions)
6162
- [Communication](#communication)
@@ -1125,6 +1126,22 @@ NSString *callbackId = [chan bindWithEventName:@"new-price" eventCallback:^void
11251126
11261127
You can unbind from events at both the global and per channel level. For both objects you also have the option of calling `unbindAll`, which, as you can guess, will unbind all eventHandlers on the object.
11271128
1129+
## Triggering events
1130+
1131+
Once a [private](https://pusher.com/docs/channels/using_channels/private-channels) or [presence](https://pusher.com/docs/channels/using_channels/presence-channels) subscription has been authorized (see [authenticating users](https://pusher.com/docs/channels/server_api/authenticating-users)) and the subscription has succeeded, it is possible to trigger events on those channels.
1132+
1133+
```swift
1134+
chan.trigger(eventName: "client-myEvent", data: ["myName": "Bob"])
1135+
```
1136+
1137+
Events triggered by clients are called [client events](https://pusher.com/docs/channels/using_channels/events#triggering-client-events). Because they are being triggered from a client which may not be trusted there are a number of enforced rules when using them. Some of these rules include:
1138+
1139+
* Event names must have a `client-` prefix
1140+
* Rate limits
1141+
* You can only trigger an event when the subscription has succeeded
1142+
1143+
For full details see the [client events documentation](https://pusher.com/docs/channels/using_channels/events#triggering-client-events).
1144+
11281145
## Testing
11291146

11301147
There are a set of tests for the library that can be run using the standard method (Command-U in Xcode).

0 commit comments

Comments
 (0)