XMPPFramework - iOS 中未收到存在信息

发布于 2024-12-18 20:29:29 字数 902 浏览 2 评论 0原文

我正在尝试将消息从模拟器发送到设备。在模拟器上有一个用户,而在设备上有另一个用户。但无论如何都没有收到存在感。 我正在使用适用于 ios 的 XMPPFramework。 这是我用来发送状态的代码

NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"[email protected]"]];
[presence addAttributeWithName:@"type" stringValue:@"available"];
[[self xmppStream] sendElement:presence]; 

,但在最后 [email  protected] 已登录,未调用以下方法

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
    NSLog(@"---------- xmppStream:didReceivePresence: ----------");
}

可能是什么问题?

I am trying to send message from simulator to device. On simulator there is one user while on device there is another user. But presence is not being received at any end.
I am using XMPPFramework for ios.
Here is the code I am using to send presence

NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"[email protected]"]];
[presence addAttributeWithName:@"type" stringValue:@"available"];
[[self xmppStream] sendElement:presence]; 

But at the end where [email protected] is logged in following method is NOT being invoked

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
    NSLog(@"---------- xmppStream:didReceivePresence: ----------");
}

What might be the issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2024-12-25 20:29:29

未发送存在的原因是代码不正确。我使用以下代码发送存在状态

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

,之后它显示用户在 openfire 服务器上在线,并且消息已正确发送给其他用户。

The reason presence was not being sent is that code was incorrect. I used following code to send presence

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

after that it showed user online on openfire server and message was correctly being sent to other users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文