已取消订阅频道,仍在频道中 [英] Unsubscribed from channel, still on channel

查看:74
本文介绍了已取消订阅频道,仍在频道中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 PubNub 用于 IOS 应用程序(IOS SDK 8.0).当我尝试取消订阅applicationDidEnterBackground"事件的频道时,我得到以下控制台输出.它说该频道已取消订阅,但是当我从管理控制台查看时,我仍在该频道上.你能就此给出一些建议吗?

I am using PubNub for an IOS app (IOS SDK 8.0). When I am trying to unsubscribe from a channel on "applicationDidEnterBackground" event, I get the following console output. It says the channel is unsubscribed, but when I check from admin console I am still on the channel. Can you give some advice on this ?

这是我在applicationDidEnterBackground"中使用的行:

Here is the line I am using in "applicationDidEnterBackground":

PubNub.unsubscribeFromChannel(channelToReceive,{(list, err:PNError!)-> Void in
        if(err != nil){
            println(err.localizedFailureReason)
        } else {
            println("Unsubscribed...")
        }
    })

这是applicationDidEnterBackground"事件后的 PubNub 控制台输出:

Here is the PubNub console output after "applicationDidEnterBackground" event:

2014-11-08 14:47:16.585 Chat[263:60b] PubNub (0x14d7a2b0) TRYING TO UNSUBSCRIBE FROM CHANNELS: (
    "PNChannel(0x14d28150) b905359780766"
) (STATE: 'connected')
2014-11-08 14:47:16.587 Chat[263:60b] PubNub (0x14d7a2b0) UNSUBSCRIBE FROM CHANNELS (STATE: 'connected')
2014-11-08 14:47:16.590 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] LEAVING SPECIFIC SET OF CHANNELS... (STATE: 10)
2014-11-08 14:47:16.625 Chat[263:60b] PubNub (0x14d7a2b0) WILL UNSUBSCRIBE FROM CHANNELS: (
    "PNChannel(0x14d28150) b905359780766",
    "PNChannelPresence(0x14dc64f0) b905359780766-pnpres"
) (STATE: 'connected')
2014-11-08 14:47:16.632 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::WRITE] WRITE BUFFER CONTENT (STATE: 33683456)
2014-11-08 14:47:16.640 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] WILL START REQUEST PROCESSING: <PNLeaveRequest|/v2/presence/sub_key/sub*****7fe/channel/b905359780766/leave?uuid=b905359780766&callback=lv_7cba2&pnsdk=PubNub-ObjC-iOS%2F3.6.7> (STATE: 8)
2014-11-08 14:47:16.645 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] RECONNECTING BY REQUEST... (STATE: 8)
2014-11-08 14:47:16.668 Chat[263:60b] PNReachability (0x14d88c00) PUBNUB SERVICES REACHABILITY CHANGED W/O EVENT [CONNECTED? 1 | NETWORK ADDRESS: 192.168.1.6](FLAGS: 65538)
2014-11-08 14:47:16.673 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] TRYING TO RECONNECT... (STATE: 100792320)
2014-11-08 14:47:16.677 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] DESTROYING STREAMS... (STATE: 100792328)
2014-11-08 14:47:16.684 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] UNSCHEDULE REQUEST SENDING (32795e5c-a2cb-475b-993a-61077ea21744) (STATE: 67237896)
2014-11-08 14:47:16.690 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] DID CANCEL REQUEST: <PNLeaveRequest|/v2/presence/sub_key/sub*****7fe/channel/b905359780766/leave?uuid=b905359780766&callback=lv_7cba2&pnsdk=PubNub-ObjC-iOS%2F3.6.7> (STATE: 0)
2014-11-08 14:47:16.714 Chat[263:60b] PNReachability (0x14d88c00) PUBNUB SERVICES REACHABILITY CHANGED W/O EVENT [CONNECTED? 1 | NETWORK ADDRESS: 192.168.1.6](FLAGS: 65538)
2014-11-08 14:47:16.720 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::READ] DESTROYING... (STATE: 129032)
2014-11-08 14:47:16.726 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::READ] DESTROYED. (STATE: 126984)
2014-11-08 14:47:16.731 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::WRITE] DESTROYING... (STATE: 126984)
2014-11-08 14:47:16.742 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::WRITE] DESTROYED. (STATE: 122888)
2014-11-08 14:47:16.748 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] READ AND WRITE STREAMS DESTROYED (STATE: 12582920)
2014-11-08 14:47:16.757 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::WRITE] WRITE CANCELED (STATE: 12582920)
2014-11-08 14:47:29.679 Chat[263:60b] PubNub (0x14d7a2b0) HANDLE APPLICATION ENTERED BACKGROUND (STATE: 'connected')
2014-11-08 14:47:36.587 Chat[263:60b] PubNub (0x14d7a2b0) APPLICATION CAN'T RUN IN BACKGROUND (STATE: 'connected')
2014-11-08 14:47:36.591 Chat[263:60b] PNReachability (0x14d88c00) REACHABILITY OBSEVATION SUSPENDED
2014-11-08 14:47:36.594 Chat[263:60b] PubNub (0x14d7a2b0) SUSPENDING... (STATE: 'connected')
2014-11-08 14:47:36.597 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] TRYING TO SUSPEND (STATE: 10)
2014-11-08 14:47:36.600 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] SUSPENDING... (STATE: 10)
2014-11-08 14:47:36.602 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] TRYING TO DISCONNECT... (BY USER REQUEST? 0) (STATE: 12582912)
2014-11-08 14:47:36.604 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::READ] DISCONNECTING... (STATE: 12582912)
2014-11-08 14:47:36.606 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] HANDLE STREAM CONNECTION CLOSED (STATE: 8912896)
2014-11-08 14:47:36.611 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier::WRITE] DISCONNECTING... (STATE: 8912896)
2014-11-08 14:47:36.613 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] HANDLE STREAM CONNECTION CLOSED (STATE: 1572864)
2014-11-08 14:47:36.615 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] DISCONNECTED (STATE: 12582912)
2014-11-08 14:47:36.617 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION::PNMessagingConnectionIdentifier] NOTIFY DELEGATE ABOUT DISCONNECTION (STATE: 12582912)
2014-11-08 14:47:36.619 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] HANDLE DISCONNECTION EVENT (STATE: 24)
2014-11-08 14:47:36.634 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] LEAVE REQUEST COMPLETED (STATE: 0)
2014-11-08 14:47:36.637 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] PRESENCE 'LEAVE' REQUEST ERROR: Domain=com.pubnub.pubnub; Code=107; Description="PubNub client can't perform request"; Reason="Looks like the client lost it's net connection"; Fix suggestion="Ensure that all network configuration (including any proxy) is correct, and try again."; Associated object=(null)\nCHANNELS: (
    "PNChannel(0x14d28150) b905359780766",
    "PNChannelPresence(0x14dc64f0) b905359780766-pnpres"
)\n(STATE: 0)
2014-11-08 14:47:36.641 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] UNSUBSCRIBED FROM CHANNELS: (
    "PNChannel(0x14d28150) b905359780766",
    "PNChannelPresence(0x14dc64f0) b905359780766-pnpres"
)\n(STATE: 0)
2014-11-08 14:47:36.648 Chat[263:60b] PubNub (0x14d7a2b0) SHOULD CHANNEL PNMessagingConnectionIdentifier (0x14d69800) NOTIFY DELEGATE? 0 (STATE: 'suspended')
2014-11-08 14:47:36.651 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] HANDLE SUSPENSION EVENT (STATE: 24)
2014-11-08 14:47:36.653 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] SUSPENDED (STATE: 160)
2014-11-08 14:47:36.655 Chat[263:60b] PNServiceChannel (0x14d90d00) [CHANNEL::PNServiceConnectionIdentifier] TRYING TO SUSPEND (STATE: 8)
2014-11-08 14:47:36.665 Chat[263:60b] PNServiceChannel (0x14d90d00) [CHANNEL::PNServiceConnectionIdentifier] SUSPENDING... (STATE: 8)
2014-11-08 14:47:36.671 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier] TRYING TO DISCONNECT... (BY USER REQUEST? 0) (STATE: 2226176)
2014-11-08 14:47:36.675 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::READ] DISCONNECTING... (STATE: 2201600)
2014-11-08 14:47:36.679 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::READ] DESTROYING... (STATE: 2725888)
2014-11-08 14:47:36.699 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::READ] DESTROYED. (STATE: 2723840)
2014-11-08 14:47:36.703 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier] HANDLE STREAM CONNECTION CLOSED (STATE: 2723840)
2014-11-08 14:47:36.706 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::WRITE] DISCONNECTING... (STATE: 2723840)
2014-11-08 14:47:36.710 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::WRITE] DESTROYING... (STATE: 3772416)
2014-11-08 14:47:36.718 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier::WRITE] DESTROYED. (STATE: 3768320)
2014-11-08 14:47:36.721 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier] HANDLE STREAM CONNECTION CLOSED (STATE: 3768320)
2014-11-08 14:47:36.724 Chat[263:60b] PNConnection (0x14d959d0) [CONNECTION::PNServiceConnectionIdentifier] SUSPENDED (STATE: 12582912)
2014-11-08 14:47:36.727 Chat[263:60b] PNServiceChannel (0x14d90d00) [CHANNEL::PNServiceConnectionIdentifier] HANDLE SUSPENSION EVENT (STATE: 24)
2014-11-08 14:47:36.739 Chat[263:60b] PNServiceChannel (0x14d90d00) [CHANNEL::PNServiceConnectionIdentifier] SUSPENDED (STATE: 160)

提前致谢.

推荐答案

您仍然处于连接状态,因为 pubnub 在后台没有发送任何通知.更棘手的是,它会在返回前台时发送排队的通知.

You are still connected because pubnub didn't send any notification while in background. Even more tricky, it will send the queued notif when coming back to foreground.

为了让 Pubnub 在后台运行,您必须启用适当的后台模式.一个需要 websockets(pubnub 也使用它们)在左侧选择您的项目并转到 Capabilities 选项卡.在那里你会找到所有你可以启用的背景模式.对于 Pubnub,我听说 VOIP 和位置更新可以使用.

In order to have Pubnub run in the background, you have to enable the appropriate background modes. One that needs websockets (pubnub also uses them) Select your project on the left and go to the Capabilities tab. In there you will find all the background modes you can enable. For Pubnub, I hear VOIP and and Location Updates will work.

我个人选择位置更新.请记住,如果您不将定位服务用于实际定位服务,Apple 将拒绝您的应用.正在使用 Pubnub 进行一些研究,这对我来说很好,但是当我部署时,我可能会切换到 HTTP 请求,因为它们被允许在后台运行.

I personally choose location updates. Keep in mind that Apple will reject your app if you don't use location services for actual location services. Being doing some research with Pubnub it's fine by me but when I'll deploy I might switch to HTTP request since they are allowed to run in the background.

这篇关于已取消订阅频道,仍在频道中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆