<分区>
我下载了 iOS Hello World 应用程序并开始运行。我正在尝试将其放入我自己的应用程序中,但在订阅该 channel 时遇到问题。
标题:
@property (nonatomic, strong) PNChannel *currentChannel;
@property (nonatomic, strong) PNConfiguration *pubnubConfig;
实现:
_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];
}
}];
运行时报错:
我不明白为什么它不起作用,尤其是当其中大部分已从演示代码中删除时。没有连接问题,因为演示项目工作正常。非常感谢帮助,谢谢!