2013-04-12 296 views
0

我在我的应用程序中使用XMPP。每当我尝试将消息发送到任何特定的ID(例如,我的代码中的'[email protected]')时,我的消息都不会被发送。 我的代码如下。提前致谢。未通过XMPP发送的消息

- (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:@"[email protected]"]; 
    [message addChild:body]; 

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

回答

0

你的代码对我来说看起来很好。 Google Talk只将消息路由到您订阅的联系人。用户是否将邮件发送到您的联系人列表中?

+0

是的,用户在我的联系人列表中。 – John

+0

然后请将xml日志添加到您的问题 – Alex

0

打印xml,然后查看消息中的内容。可能是您将消息发送给错误的JID。