The community forums are in BETA and closed to the public.

How to leave channel perfectly ( iOS ) ?


We are making a simple app by which we show user Online/Offline status. For that we create a channel name "xyz" and all members will subscribe this channel with different "client identifier". When any new user will join the channel, we are getting "join" (event.type=PNPresenceEventJoin in didReceivePresenceEvent delegate method). It's perfect.

But we are not getting "leave" status after unsubscribe this channel .

For Unsubscribe we have user below method :

[PubNub unsubscribeFrom:[NSArray arrayWithObjects:[PNChannel channelWithName:@"xyz" shouldObservePresence:YES], nil] withCompletionHandlingBlock:^(NSArray *channels, PNError *error) {


It show me that i am unsubscribe this channel successfully. But other members of this channel not getting any message regarding this.

What should i do for this ?

Which process i should have to do so that all other member will get "event.type==PNPresenceEventLeave" in didReceivePresenceEvent delegate method ?

Please also give code to leave a channel perfectly.

Useful Information regarding my code:

  • I have set below things for Pubnub. PNConfiguration *myConfig=[PNConfiguration configurationForOrigin:@"" publishKey:@xxxxxxxxxx" subscribeKey:@"yyyyyyyyyy" secretKey:@"zzzzzzzzzzz"]; myConfig.presenceHeartbeatInterval=3; myConfig.presenceHeartbeatTimeout=3; [PubNub setConfiguration:myConfig]; [PubNub connect];

  • And after this i subscribe that channel like below :

NSString *uuid=[NSString stringWithFormat:@10001"]; // Its different for all device user. [PubNub setClientIdentifier:uuid]; [PubNub subscribeOn:[NSArray arrayWithObjects:[PNChannel channelWithName:@"xyz" shouldObservePresence:YES], nil]];

Comments to this discussion are now closed!