无法取消订阅android中的pubnub

时间:2014-09-02 14:14:03

标签: android pubnub

我使用unsubscribe(channelname)取消订阅pubnub但我的android应用程序无法取消订阅此频道。我从这个频道收到消息。

我使用以下代码从pubnub订阅

 mPubnub = new Pubnub("", subsriberkey);
            mPubnub.setCacheBusting(false);
            mPubnub.setAuthKey(authToken)

mPubnub.subscribe(channelname, pubnubConnectionCallback);


private Callback pubnubConnectionCallback = new  Callback() {
        @Override
        public void connectCallback(String channel,
                                    Object message) {

            showToast("SUBSCRIBE : CONNECT on channel:"
                    + channel
                    + " : "
                    + message.getClass()
                    + " : "
                    + message.toString());
        }

         @Override
         public void disconnectCallback(String channel,
                                        Object message) {
             showToast("SUBSCRIBE : DISCONNECT on channel:"
                     + channel
                     + " : "
                     + message.getClass()
                     + " : "
                     + message.toString());
         }

         @Override
         public void reconnectCallback(String channel,
                                       Object message) {
             showToast("SUBSCRIBE : RECONNECT on channel:"
                     + channel
                     + " : "
                     + message.getClass()
                     + " : "
                     + message.toString());
         }

         @Override
         public void successCallback(String channel,
                                     Object message) {
//           showToast("SUBSCRIBE : " + channel + " : "
//                     + message.getClass() + " : "
//                     + message.toString());
             showToast(message.toString());
         }

         @Override
         public void errorCallback(String channel,
                                   PubnubError error) {
             showToast("SUBSCRIBE : ERROR on channel "
                     + channel + " : "
                     + error.toString());
         }
    };

以下代码取消订阅pubnub

mPubnub.unsubscribe(channelName);

0 个答案:

没有答案