简体   繁体   English

如何知道用户在iOS的quickblox中在线还是离线?

[英]How to know user is online or offline in quickblox for iOS?

I am storing user contact in arrContactList 我将用户联系人存储在arrContactList中

NSArray *arrContactList =  [QBChat instance].contactList.contacts;

From arrContactList, how the presence status can be derived. 从arrContactList,如何得出状态。

Also after getting presence status, if user goes online or offline, how it can be found. 同样在获得在线状态后,如果用户联机或脱机,如何找到它。

// contact has userId and presence status //联系人具有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);
    }
}

// When a contact user goes online or offline, this method gets called //当联系人用户在线或离线时,将调用此方法

- (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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM