• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ios - 已退订 channel ,仍在 channel 中

[复制链接]
菜鸟教程小白 发表于 2022-12-12 12:34:56 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我将 PubNub 用于 IOS 应用程序(IOS SDK 8.0)。当我尝试取消订阅有关“applicationDidEnterBackground”事件的 channel 时,我得到以下控制台输出。它说 channel 已取消订阅,但是当我从管理控制台检查时,我仍在 channel 上。可以给点建议吗?

这是我在“applicationDidEnterBackground”中使用的行:

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

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

2014-11-08 14:47:16.585 Chat[263:60b] PubNub (0x14d7a2b0) TRYING TO UNSUBSCRIBE FROM CHANNELS: (
    "NChannel(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:NMessagingConnectionIdentifier] LEAVING SPECIFIC SET OF CHANNELS... (STATE: 10)
2014-11-08 14:47:16.625 Chat[263:60b] PubNub (0x14d7a2b0) WILL UNSUBSCRIBE FROM CHANNELS: (
    "NChannel(0x14d28150) b905359780766",
    "NChannelPresence(0x14dc64f0) b905359780766-pnpres"
) (STATE: 'connected')
2014-11-08 14:47:16.632 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION:NMessagingConnectionIdentifier::WRITE] WRITE BUFFER CONTENT (STATE: 33683456)
2014-11-08 14:47:16.640 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL:NMessagingConnectionIdentifier] WILL START REQUEST PROCESSING: <NLeaveRequest|/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:NMessagingConnectionIdentifier] 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:NMessagingConnectionIdentifier] TRYING TO RECONNECT... (STATE: 100792320)
2014-11-08 14:47:16.677 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION:NMessagingConnectionIdentifier] DESTROYING STREAMS... (STATE: 100792328)
2014-11-08 14:47:16.684 Chat[263:60b] PNConnection (0x14d5cd40) [CONNECTION:NMessagingConnectionIdentifier] UNSCHEDULE REQUEST SENDING (32795e5c-a2cb-475b-993a-61077ea21744) (STATE: 67237896)
2014-11-08 14:47:16.690 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL:NMessagingConnectionIdentifier] DID CANCEL REQUEST: <NLeaveRequest|/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:NMessagingConnectionIdentifier::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="ubNub 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: (
    "NChannel(0x14d28150) b905359780766",
    "NChannelPresence(0x14dc64f0) b905359780766-pnpres"
)\n(STATE: 0)
2014-11-08 14:47:36.641 Chat[263:60b] PNMessagingChannel (0x14d69800) [CHANNEL::PNMessagingConnectionIdentifier] UNSUBSCRIBED FROM CHANNELS: (
    "NChannel(0x14d28150) b905359780766",
    "NChannelPresence(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)

提前致谢。



Best Answer-推荐答案


好吧,如果您的应用程序不能在后台持久运行,那么当应用程序转移到后台执行状态时,您就不能调用此类命令。 您可以尝试使用此回调执行一些请求,然后 PubNub 客户端将与您的应用程序一起暂停:

- (void)pubnubClientPubNub *)client willSuspendWithBlockvoid(^)(void(^)(void(^)(void))))preSuspensionBlock {

    if ([client isConnected]) {

        preSuspensionBlock(^(void(^completionBlock)(void)){

            // Do last calls here
            // Always call this block as soon as required amount of tasks completed.
            completionBlock();
        }];
    });
  }
}

关于ios - 已退订 channel ,仍在 channel 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26817421/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap