Search code examples
iosobjective-cchatquickblox

QuickBlox How to check QBChat/didDisconnect to force the user to login again?


I want to check QBChat/didDisconnect in my code because i want to force the user to log in again to the app when QBChat/didDisconnect. I am already using the following method but sometimes it got ERROR like the following:

QBChat/didDisconnect, error: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo=0x9ca1260 {NSLocalizedDescription=Socket closed by remote peer} ;

- (void)sendPresence{
    // presence in QuickBlox Chat
    [[QBChat instance] sendPresence];
    // presence in QuickBlox
    [QBUsers userWithExternalID:1 delegate:nil];
}

By the way, after creating a chat room with "[[QBChat instance] createOrJoinRoomWithName:@"name" membersOnly:NO persistent:YES];", it takes time to work out the following method. And Sometimes, that method is not called properly.

- (void)chatRoomDidEnter:(QBChatRoom *)room{
}

Solution

  • You can use QBChatDelegate's method

    -(void)chatDidFailWithError:(int)code
    {
    }
    

    If it was manual logout - code will be equal to 0