我正在 iOS 上开发并使用 Robbie Hanson XMPPFramework。永远不会调用方法 didReceiveMessage。
我确实成功连接,并发送了“存在”(通过使用 NSLog 确认。这可以通过 Openfire 管理面板确认,该面板显示用户为绿色且已连接。
XMPPPresence* presence = [XMPPPresence presence]; // type="available" is implicit
[[self xmppStream] sendElement:presence];
此外,我收到了 didReceiveIQ 调用。我不知道什么是 IQ,我需要处理它吗?
最重要的是我是否让 didReceiveMessage 被调用。谢谢!
最佳答案
要记住的一件事是,在身份验证之后,您需要发送出席信息,否则您将不会收到任何消息。
阅读以下博文:Build a complete iOS messaging app using XMPPFramework - Tutorial Part 1
After a sucessfull connection, you are not going to receive any
<message/>
until you make yourself available sending the previous presence.<presence/>
你的代码中应该有这样的东西:
func xmppStreamDidAuthenticate(_ sender: XMPPStream!) {
self.xmppStream.send(XMPPPresence())
print("Stream: Authenticated")
}
如果您查看我发布的教程的第二部分,您将了解如何执行身份验证和所有操作:
Build a complete iOS messaging app using XMPPFramework - Part 2
关于iphone - 未调用 RobbieHanson 的 XMPPFramework didReceiveMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14618155/