【发布时间】:2017-06-27 13:30:43
【问题描述】:
我想获得离线用户(朋友)状态:
当用户在线时我的代码工作正常,所以我得到了用户状态但是当他离线时user.primaryResource.presence.status 给出了nil 值。
XMPPUserCoreDataStorageObject *user = [[self fetchedResultsController] objectAtIndexPath:indexPath];
NSLog(@"Status: %@",user.primaryResource.presence.status);
用户下线后,我检查XMPPResourceCoreDataStorageObject 表中的特定jidStr 它给我零个对象意味着当用户下线时它会删除该用户的ResourcesObject。
因此,有可能获得该用户的状态。
【问题讨论】:
-
你的意思是用户的状态是
Online还是Offline?如果是,那么如果presense给你 nil 不意味着用户是Offline吗? -
Status 表示存在状态,保存在 XMPPResourceCoreDataStorageObject -> object -> primaryResource 中,因此,当用户离线时,XMPPResourceCoreDataStorageObject 对象变为 nil。
-
你尝试过 XMPPRosterCoreDataStorage 吗?
-
@dichen 是的,我也尝试过 XMPPRosterCoreDataStorage 函数: - (XMPPUserCoreDataStorageObject *)userForJID:(XMPPJID *)jid xmppStream:(XMPPStream *)stream managedObjectContext:(NSManagedObjectContext *)moc 但它也返回 nil用户下线时的价值。
标签: ios objective-c xmpp xmppframework