我正在使用 XMPP 开发基于聊天的应用程序。我被困在获取用户上线或下线的通知。
当任何名册好友上线或下线时,不会调用以下方法。
- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
NSString *presenceType = [presence type]; // online/offline
NSString *myUsername = [[sender myJID] user];
NSString *presenceFromUser = [[presence from] user];
if (![presenceFromUser isEqualToString:myUsername])
{
if ([presenceType isEqualToString:@"available"]) {
// [_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"chat.denederlandsewateren.nl"]];
} else if ([presenceType isEqualToString:@"unavailable"]) {
// [_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"chat.denederlandsewateren.nl"]];
}
}
}
请建议我或指导我如何处理- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
问候,