在 xcode 中使用 xmpp 发送 Facebook 消息失败

Posted

技术标签:

【中文标题】在 xcode 中使用 xmpp 发送 Facebook 消息失败【英文标题】:Facebook message sending failed using xmpp in xcode 【发布时间】:2013-09-19 10:59:00 【问题描述】:

我正在使用此代码发送消息,但我的消息未送达。 而我收到从 facebook 发送的消息。 请帮助我,因为我不知道我做错了什么。

if([textMessage length] > 0)
    NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
    [body setStringValue:textMessage];
    NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
    [message addAttributeWithName:@"xmlns" stringValue:@"http://www.facebook.com/xmpp/messages"];
    [message addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"-%@@chat.facebook.com",friendID]];
    [message addChild:body];
    [self.xmppStream sendElement:message];

【问题讨论】:

谢谢,问题已解决 【参考方案1】:

以防万一其他人遇到同样的问题,“xmlns”属性必须从 Facebook url 更改为“jabber:client”才能工作。

【讨论】:

以上是关于在 xcode 中使用 xmpp 发送 Facebook 消息失败的主要内容,如果未能解决你的问题,请参考以下文章