gpt4 book ai didi

ios - 如何在 iOs 中获取用户的可用性通知?

转载 作者:行者123 更新时间:2023-11-29 01:07:19 26 4
gpt4 key购买 nike

我正在使用 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

问候,

最佳答案

我认为您需要使用以下代码发送状态:

NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[xmppStream sendElement:presence];

XMPPPresence *presence = [XMPPPresence presence];
[[self xmppStream] sendElement:presence];

所以在那之后我猜测调用了以下方法:

 -(void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence

关于ios - 如何在 iOs 中获取用户的可用性通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36197198/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com