我接收來自Google Talk帳戶的消息,它們顯示在Ios仿真器的表視圖中,但是當我發送它時,它不顯示在Google Talk客戶端(在另一臺計算機中)中。這是代碼:XMPPFramework消息未發送
-(IBAction)sendchat:(id)sender
{
General *general = [General sharedManager];//It is a singleton class used to store some values that need to be accesible in the whole application.
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
text=[mensaje text];
NSLog(@"Texto en el body: %@", text);
[body setStringValue:text];
NSArray *dest=[general.firstfrom componentsSeparatedByString:@"/"];//in firstfrom is stored the account from wich we receive the first message. This app cannot start a conversation itself, must only answer
NSLog(@"Destination trimmed: %@", [dest objectAtIndex:0]);//Here, the destination account shows correctly (without the /xxxx stuff, just [email protected])
XMPPMessage *mens=[[XMPPMessage alloc]init];
[mens addAttributeWithName:@"body" stringValue:text];
[mens addAttributeWithName:@"sender" stringValue:general.userlogin];
NSLog(@"text vale: %@", text);
NSXMLElement *messagetosend = [NSXMLElement elementWithName:@"message"];
[messagetosend addAttributeWithName:@"type" stringValue:@"chat"];
[messagetosend addAttributeWithName:@"to" stringValue:[dest objectAtIndex:0]];
[messagetosend addChild:body];
NSLog(@"We are sending to: %@", [dest objectAtIndex:0]);
[self.xmppStream sendElement:messagetosend];
[self xmppStream:xmppStream didReceiveMessage:mens];//manage the sent message as it was received, to show it in the Table View
[email protected]"";
}
正如我所說,郵件接收完美,但我不能發送。我見過很多關於如何發送的例子,他們就像我的代碼。如果我調試發件人,它顯示ok([email protected]),並且「to」屬性也可以([email protected])。 xmppStrem設置正確(據我所知):
xmppStream = [[XMPPStream alloc] init];
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
在ViewDidLoad方法。
任何幫助?謝謝。
---編輯---
我忘了說,這兩個帳戶知道對方,並在谷歌Talk客戶端,存在被髮送。
沒有人可以幫助我嗎? :( – Fustigador
你應該檢查jid值..我不記得但我認爲他們不同於emailID。 – harshalb
嗨,你可以請指導我如何添加XMPPFramework,我GOOGLE了,但鏈接給404錯誤..一些XMPPFrameworks我下載了像iPhoneXMPP,但它給錯誤..請指導我@Fustigador – Babul