【问题标题】:RobbieHanson's XMPPFramework didReceiveMessage not calledRobbieHanson 的 XMPPFramework didReceiveMessage 未调用
【发布时间】:2013-01-15 02:29:58
【问题描述】:

我正在 iOS 上开发并使用 Robbie Hanson XMPPFramework。永远不会调用方法 didReceiveMessage。

我确实成功连接,并发送了“存在”(通过使用 NSLog 确认。这可以通过 Openfire 管理面板确认,该面板显示用户为绿色并已连接。

    XMPPPresence* presence = [XMPPPresence presence]; // type="available" is implicit
[[self xmppStream] sendElement:presence];

此外,我收到了 didReceiveIQ 电话。我不知道什么是智商,我需要处理它吗?

最重要的是我是否让 didReceiveMessage 被调用。谢谢!

【问题讨论】:

标签: iphone ios xmpp xmppframework


【解决方案1】:

要记住的一点是,身份验证后您需要发送出席信息,否则您将不会收到任何消息。

阅读以下博文:Build a complete iOS messaging app using XMPPFramework - Tutorial Part 1

在成功连接后,您将不会收到任何<message/>,直到您可以发送之前的出席信息。 <presence/>

你的代码中应该有这样的东西:

func xmppStreamDidAuthenticate(_ sender: XMPPStream!) {
    self.xmppStream.send(XMPPPresence())
    print("Stream: Authenticated")
}

如果您查看我发布的教程的第二部分,您将了解如何执行身份验证以及所有内容:

Build a complete iOS messaging app using XMPPFramework - Part 2

【讨论】:

    【解决方案2】:

    只有当您的客户端收到这样的消息节时才会调用 didReceiveMessage 委托:

    <message xmlns="jabber:client" from="juliet@capulet.net" to="romeo@capulet.net" id="21" type="chat"><body>This is a sample message.</body></message>
    

    如果其他 XMPP 客户端向您发送聊天消息,则会收到此节。如果您的 didReceiveIQ 已经被调用,那么我们可以假设我们已经正确设置了我们的代理。

    【讨论】:

      猜你喜欢
      • 2012-06-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-27
      • 2014-12-24
      • 1970-01-01
      • 2015-12-14
      • 2016-05-10
      • 1970-01-01
      相关资源
      最近更新 更多