【问题标题】:Message not sent through XMPP消息未通过 XMPP 发送
【发布时间】:2013-04-12 07:22:16
【问题描述】:

我在我的应用程序中使用 XMPP。每当我尝试向任何特定 ID(例如我的代码中的“test.codemen@gmail.com”)发送消息时,我的消息都不会被发送。 我的代码如下。提前致谢。

- (IBAction)sendMsg:(id)sender 
{
    NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
    [body setStringValue:msgField.text];

    NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
    [message addAttributeWithName:@"type" stringValue:@"chat"];
    [message addAttributeWithName:@"to" stringValue:@"test.codemen@gmail.com"];
    [message addChild:body];

    iPhoneXMPPAppDelegate *share = [iPhoneXMPPAppDelegate sharedInstance];
    [[share xmppStream] sendElement:message];
}

【问题讨论】:

    标签: ios objective-c xmpp xmppframework


    【解决方案1】:

    您的代码对我来说看起来不错。 Google Talk 仅将消息路由到您订阅的联系人。您向其发送消息的用户是否在您的联系人列表中?

    【讨论】:

    • 是的,该用户在我的联系人列表中。
    【解决方案2】:

    打印 xml,然后查看消息中的内容。也许您正在向错误的 JID 发送消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      • 1970-01-01
      • 2017-02-01
      • 2011-05-11
      相关资源
      最近更新 更多