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
Solution 1:
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
Solution 2:
Use latest version of quickblox. Current version is 1.1.
You have to send presence after login with timeer according to this documentation. http://quickblox.com/developers/Android_XMPP_Chat_Sample
After login
QBChatService.getInstance().startAutoSendPresence(60);
Hope this will solve.
Solution 3:
Use this way when using Quickblox SDK 2.0
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void connected(XMPPConnection connection) {
}
@Override
public void authenticated(XMPPConnection connection) {
}
@Override
public void connectionClosed() {
}
@Override
public void connectionClosedOnError(Exception e) {
// connection closed on error. It will be established soon
}
@Override
public void reconnectingIn(int seconds) {
}
@Override
public void reconnectionSuccessful() {
}
@Override
public void reconnectionFailed(Exception e) {
}
};
QBChatService.getInstance().addConnectionListener(connectionListener);
Post a Comment for "Quickblox One To One Chat Connection Lost"