Search code examples
androidxmppchatquickblox

Quickblox one to one chat connection lost


I have developed chat application using Quickblox SDK version 0.8.1. Sometimes app loses chat connection to the server so can not send message or receive message even in same chat page. I do have to reload every time this happens even sometimes it does not re-connect. So can any body help me with this.


Solution

  • To reconnect to Chat please do:

    iOS way

    - (void)chatDidFailWithError:(int)code
    {
        // reconnect
        [[QBChat instance] loginWithUser:[LocalStorageController shared].qbUser];
    }
    

    Android way (SDK 1.1 version)

    // initialize SMACK
    SmackAndroid.init(this);
    
    final QBUser user = new QBUser("garry", "garry2892pass");
    user.setId(4234);
    QBChatService.getInstance().loginWithUser(user, LoginActivity.this);
    
    
    @Override
    public void onLoginSuccess() {
        Log.d(TAG, "success when login");
    }
    
    @Override
    public void onLoginError() {
        Log.e(TAG, "error when login");
    }
    
    @Override
    public void onDisconnect() {
        Log.d(TAG, "disconnect when login");
    
        // Relogin here
    }
    
    @Override
    public void onDisconnectOnError(Exception exc) {
        Log.e(TAG, "disconnect error when login", exc);
    
        // Relogin here
    }
    

    More info here http://quickblox.com/developers/Android_XMPP_Chat_Sample

    Just update Android SDK to 1.1 here http://quickblox.com/developers/Android#Download_Android_SDK