0
試圖創建一個非常簡單的概念驗證iOS xmpp應用與robbiehanson xmpp frame work,只需要能夠發送和接收消息和名冊數據。我可以成功驗證併發送消息,但當用戶嘗試回覆我的消息時,我不會收到它們。我已實施didReceiveMessage委託方法如下:Robbiehanson xmpp框架的iOS不接收聊天消息
-(void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message {
NSLog(@"incoming message: %@", message);
}
但我從來沒有收到此日誌。如果我使用與此xmpp服務器通信的現有web應用程序或android應用程序登錄,我會收到這些消息,因此我傾向於認爲它們的格式正確。是否有需要添加到XMPPStream接收消息的模塊?我設置了這樣的流(某些字符串值已被更改爲安全,什麼不可以):
stream = [[XMPPStream alloc] init];
stream.enableBackgroundingOnSocket = YES;
stream.hostName = @"hostname.com";
stream.hostPort = 5222;
XMPPRosterCoreDataStorage* xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];
XMPPRoster* xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];
xmppRoster.autoFetchRoster = YES;
xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;
[stream addDelegate:self delegateQueue:dispatch_get_main_queue()];
XMPPJID* jid = [XMPPJID jidWithUser:@"username" domain:@"domain.com" resource:@"iOS"];
[stream setMyJID:jid];
[xmppRoster activate:stream];
[stream connectWithTimeout:XMPPStreamTimeoutNone error:&error]
然後在xmppStreamDidConnect方法我這樣做是爲了驗證
NSString *myPassword = @"password";
NSError *error = nil;
[stream authenticateWithPassword:myPassword error:&error]
當我發送消息出來我用這個片段:
MPPJID* recipient = [XMPPJID jidWithString:@"[email protected]"];
XMPPMessage* message = [[XMPPMessage alloc] initWithType:@"chat" to:recipient];
[message addBody:@"hello world"];
[stream sendElement: message];
我想有一些簡單的我失蹤,有人誰已經在此之前使用就能夠正確指出我遠。如果需要解決此問題,我已準備好提供其他信息。