You forgot to connect right after +setConfiguration:
Cannot subscribe to pubnub channel (error 107) [closed]
-
29-06-2023 - |
Question
I downloaded the iOS Hello World app and got it working. I am trying to put it into my own app and am having problems subscribing to the channel.
Header:
@property (nonatomic, strong) PNChannel *currentChannel;
@property (nonatomic, strong) PNConfiguration *pubnubConfig;
Implementation:
_pubnubConfig = [PNConfiguration configurationForOrigin:@"pubsub.pubnub.com" publishKey:@pubKey subscribeKey:subKey secretKey:secKey];
[PubNub setConfiguration:_pubnubConfig];
self.currentChannel = [PNChannel channelWithName:@"tester" shouldObservePresence:NO];
[PubNub subscribeOnChannel:self.currentChannel withCompletionHandlingBlock:^(PNSubscriptionProcessState state, NSArray *channels, PNError *subscriptionError) {
NSString *alertMessage = [NSString stringWithFormat:@"Subscribed on channel: %@",self.currentChannel.name];
if (state == PNSubscriptionProcessNotSubscribedState) {
alertMessage = [NSString stringWithFormat:@"Failed to subscribe on: %@", subscriptionError ];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Subscribe" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}];
I get this error when running:
I can't understand why it won't work, especially when most of this is lifted off the demo code. There is no connection problem as the demo project works fine. Would appreciate help, thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow