QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
397 stars 358 forks source link

How to find if a user came online or go offline during chat? #722

Closed marshad13 closed 7 years ago

marshad13 commented 7 years ago

In my app i wanted to know, during my chat if one of my linked users go offline or came online, is there any delegate method in QBChat? I have checked this QBChat delegate but didn't get anything, - (void)chatDidReceiveContactItemActivity:(NSUInteger)userID isOnline:(BOOL)isOnline status:(nullable NSString *)status

It might be because my contact list is empty, By the way i find my friends using '[QBRequest usersWithIDs:]'

Here is version info, "QB-OS" = "iOS 10.1.1" "QB-SDK" = "iOS 2.9" "QuickBlox-REST-API-Version" = "0.1.1" "QuickbloxWebRTC version" = "2.3"

ghost commented 7 years ago

Hi @marshad13, please check documentation "Contact list". Are you using Add, Confirm functionality? I can give you example:

To add users to the contact list just use the method below:

[[QBChat instance] addUserToContactListRequest:24123 completion:^(NSError * _Nullable error) {

}];

To confirm the request:

[[QBChat instance] confirmAddContactRequest:5645 completion:^(NSError * _Nullable error) {

}];
ghost commented 7 years ago

@marshad13 Any updates?

marshad13 commented 7 years ago

I am using mentioned methods to 'add' and 'confirm', but the question is same how to find if anyone one contact is go offline or come online?

ghost commented 7 years ago

Hi @marshad13, [QBChat instance].contactList.contacts contains QBContactListItem items

@interface QBContactListItem : NSObject
...
//User status (online/offline).
@property (nonatomic, assign, getter=isOnline) BOOL online;
...

You can also track contact list updates in real time by using delegate:

#pragma mark -
#pragma mark QBChatDelegate

- (void)chatContactListDidChange:(QBContactList *)contactList {
    NSLog(@"Contact list did change : %@", contactList);
}
marshad13 commented 7 years ago

So this dialog will automatically be called when someone (from my contact list) came in or go out of app right?

ghost commented 7 years ago

hi @marshad13, Sorry for the delay in our reply, yes you're right

ghost commented 7 years ago

Hi @marshad13, any updates?

ghost commented 7 years ago

The issue is closed due to no response.