【问题标题】:Cannot subscribe to pubnub channel (error 107) [closed]无法订阅 pubnub 频道(错误 107)[关闭]
【发布时间】: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


【解决方案1】:

+setConfiguration:之后你忘记连接了

【讨论】:

  • @JanTuroň 相信我,我知道我在讲述如何使用我正在编写的代码。我的回答包括响应...有一个方法叫connect,我要求在他使用+setConfiguration:后立即调用它。
  • 啊,抱歉 - 我正在做一些例行的评论,我显然很累。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多