iphone - 未调用 RobbieHanson 的 XMPPFramework didReceiveMessage

标签 iphone ios xmpp xmppframework

我正在 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/

相关文章:

iphone - iOS 7 中的 UITabBar 色调

iphone - 使用 "User Defined Runtime Attributes"在 Storyboard中本地化 View

ios - Twitter帐户代码列表可在iOS 6中使用,而不能在iOS 7中使用?

facebook - Facebook 聊天 tcp 连接如何保持事件状态?

iphone - 检测具有透明背景的 UIImage 的裁剪矩形

iphone - 从设备中检索序列号

ios - 尝试将胖二进制文件与 64 位模拟器目标链接时出错

ios - 格式字符串未使用数据参数,但它工作正常

ios - Ejabberd 推送通知配置

mysql - 将用户保存在 openfire xmpp 中的自定义表中