【发布时间】:2014-04-08 00:52:11
【问题描述】:
我下载了 iOS Hello World 应用程序并让它工作。我正在尝试将其放入我自己的应用程序中,但在订阅频道时遇到问题。
标题:
@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];
}
}];
运行时出现此错误:
我不明白为什么它不起作用,尤其是当大部分内容都从演示代码中提取出来时。演示项目工作正常,没有连接问题。非常感谢帮助,谢谢!
【问题讨论】:
-
您好,我们还通过首选支持渠道收到了您的请求。在您将项目通过电子邮件发送到我们的支持台后,我们将对其进行检查,并为您提供解决方案。
-
谢谢,下面的答案解决了我的问题。
标签: ios objective-c pubnub