我将用户联系人存储在arrContactList
中NSArray *arrContactList = [QBChat instance].contactList.contacts;
从arrContactList,可以推导出现状态。
在获得在线状态后,如果用户上线或离线,如何找到它。
答案 0 :(得分:0)
//联系人具有userId和状态
for(QBContactListItem *contact in arrContactList) {
BOOL isOnline = contact.isOnline;
NSInteger userIdValue = contact.userID;
if(isOnline) {
NSLog(@"User %ld is online",(long)userIdValue);
}
else {
NSLog(@"User %ld is offline",(long)userIdValue);
}
}
//当联系人用户上线或离线时,会调用此方法
- (void)chatDidReceiveContactItemActivity:(NSUInteger)userID isOnline:(BOOL)isOnline status:(NSString *)status{
// here you can check presence status using isOnline and also we get userID
// so list of user IDs who are online can be maintained in an array
}