0

When coming back from background, our app automatically reconnects to chat server and enters a room.

All goes well and the chat room history is loaded successfully. But all of a sudden we receive "QBChat/XEP-0045/ leavRoom" and can't send messages to room because "room is not joined".

Any thoughts on why this behaviour accours?

Mario Frade
  • 273
  • 1
  • 2
  • 11

1 Answers1

0

I recommend to use the next logic:

@property (strong, nonatomic) QBChatRoom *testRoom;

Join

[[QBChat instance] setDelegate:self];

[[QBChat instance] createOrJoinRoomWithName:@"myRoom" membersOnly:NO persistent:YES];


#pragma mark -
#pragma mark QBChatDelegate

- (void)chatRoomDidEnter:(QBChatRoom *)room{
    // retain current room
    self.testRoom = room;
}

Leave

[[QBChat instance] leaveRoom:testRoom];

#pragma mark -
#pragma mark QBChatDelegat

- (void)chatRoomDidLeave:(NSString *)roomName{
    // release room
    self.testRoom = nil;
}

I think your issue is with self.testRoom = nil;, you don't do it. But you should. Try this suggestion.

http://quickblox.com/developers/SimpleSample-chat_users-ios#Joining.2Fleaving_rooms

Rubycon
  • 18,156
  • 10
  • 49
  • 70