无法订阅pubnub频道(错误107)

时间:2014-04-08 00:52:11

标签: ios objective-c pubnub

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

运行时遇到此错误: enter image description here

我无法理解为什么它不会起作用,特别是当大部分内容从演示代码中取消时。没有连接问题,因为演示项目工作正常。非常感谢帮助,谢谢!

1 个答案:

答案 0 :(得分:3)

您忘记在+setConfiguration:

之后立即联系