Skip to content

Commit fd12431

Browse files
committed
Update README with new function
1 parent a57357e commit fd12431

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,20 @@ PusherChannel *myChannel = [pusher subscribeWithChannelName:@"my-channel"];
609609
610610
This returns PusherChannel object, which events can be bound to.
611611
612+
For non-presence channels, you can also provide a function that will be called when a client either subscribes or unsubscribes to a channel with the number of subscribers as a parameter. Also, this function is available as a parameter to `subscribe` function.
613+
614+
```swift
615+
let onSubscriptionCountChanged = { (count: Int) in
616+
let message = "\(count) subscriptions"
617+
self.message = message
618+
}
619+
620+
let channel = pusher.subscribe(
621+
channelName: "my-channel",
622+
onSubscriptionCountChanged: onSubscriptionCountChanged
623+
)
624+
```
625+
612626
### Private channels
613627

614628
Private channels are created in exactly the same way as public channels, except that they reside in the 'private-' namespace. This means prefixing the channel name:

0 commit comments

Comments
 (0)