2013-04-12 58 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。