libpush pod问题-在频道订阅期间断开连接



我在Ruby运动项目中使用libpush pod,但遇到了一个问题,我的代码在REPL中使用时工作,而不是在应用程序本身。

当我在viewDidAppear方法中尝试此代码时,它成功连接,然后在通道订阅调用期间断开连接。

当我在控制台中尝试时,它可以完美地连接和订阅。(相同的代码)

I'm trying to figure out:

  1. 为什么会发生这种情况
  2. 我应该做些什么来缓解这个问题?

我使用的是Ruby Motion的v2.31版本的1.5版本

作为参考,我也在使用促销框架,但我怀疑这与问题有任何关系。

下面是我的代码:

client = PTPusher.pusherWithKey("my_pusher_key_here", delegate:self, encrypted:true)
client.connect
channel = client.subscribeToChannelNamed("test_channel_1")
channel.bindToEventNamed('status', target: self, action: 'test_method:')

我通过将连接和订阅调用分离到单独的生命周期方法中使其工作。

我把

:

client = PTPusher.pusherWithKey("my_pusher_key_here", delegate:self, encrypted:true)
client.connect

放入viewDidLoad方法

:

channel = client.subscribeToChannelNamed("test_channel_1")
channel.bindToEventNamed('status', target: self, action: 'test_method:')

放入viewDidAppear方法。

我不能说我确切地知道为什么会这样,但我认为这与电话之间的时间有关。连接过程必须需要一点时间才能完成。

最新更新