ios - 无法订阅 pubnub channel (错误 107)

标签 ios objective-c pubnub

<分区>

我下载了 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];
        }    
     }];

运行时报错: enter image description here

我不明白为什么它不起作用,尤其是当其中大部分已从演示代码中删除时。没有连接问题,因为演示项目工作正常。非常感谢帮助,谢谢!

最佳答案

您在 +setConfiguration: 之后忘记连接了

关于ios - 无法订阅 pubnub channel (错误 107),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22925708/

相关文章:

ios - 在同步调用中执行异步任务

ios - 以编程方式在 UITableViewCell 内的 UICollectionView 内自定义 UICollectionViewCell

iphone - 修复了 UITableView 中的透明标题

android - 如何设置动态 channel 名称

ios - 绘制一个 3D 立方体并旋转它

ios - 在 ios 中弹出 View

android - 如何通过Pubnub实现一对一聊天?

websocket - 云/托管推送系统可以使用socket.io作为客户端吗?

ios - AFNetworking 3.0 错误 : “Request failed: internal server error (500)”

iphone - 将具有大量子节点的 XML 解析为 UITableView