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];
我想有一些简单的我失踪,有人谁已经在此之前使用就能够正确指出我远。如果需要解决此问题,我已准备好提供其他信息。