XMPP 聊天在 Android 和 iOS 设备之间不起作用?
我正在 Android 和 iOS 上开发 XMPP 聊天应用程序。
iPhone 模拟器和 iOS 设备之间的聊天工作正常。 它还可以在 Android 模拟器和 Android 设备之间运行。 但是,它在 Android 设备和 iOS 设备之间不起作用。
任何人都可以向我建议我可能做错了什么吗?
提前致谢...
更新:
消息是从 Android 设备发送到 iOS 设备,但不是从 iOS 发送到 Android。
我在 Android 上使用了这个:
ConnectionConfiguration connConfig = new ConnectionConfiguration(testHost,portNumber);
connection = new XMPPConnection(connConfig);
connConfig.setSASLAuthenticationEnabled(true);
我在 iOS 上使用了这个:
XMPPJID *jid=[XMPPJID jidWithString:loginDetails.username];
password=loginDetails.password;
[[self xmppStream] setMyJID:jid];
NSError *error;
if (![[self xmppStream] connect:&error])
{
NSLog(@"Error connecting: %@", error);
return NO;
}
return YES;
if (allowSelfSignedCertificates)
{
[settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
}
if (allowSSLHostNameMismatch)
{
[settings setObject:[NSNull null] forKey:(NSString *)kCFStreamSSLPeerName];
}
else
{
// Google does things incorrectly (does not conform to RFC).
// Because so many people ask questions about this (assume xmpp framework is broken),
// I've explicitly added code that shows how other xmpp clients "do the right thing"
// when connecting to a google server (gmail, or google apps for domains).
NSString *expectedCertName = nil;
NSString *serverHostName = [sender hostName];
NSString *virtualHostName = [[sender myJID] domain];
if ([serverHostName isEqualToString:@"talk.google.com"])
{
if ([virtualHostName isEqualToString:@"gmail.com"])
expectedCertName = virtualHostName;
else
expectedCertName = serverHostName;
}
else
{
expectedCertName = serverHostName;
}
[settings setObject:expectedCertName forKey:(NSString *)kCFStreamSSLPeerName];
}
I am developing an XMPP chat application on both Android and iOS.
Chatting is working fine between iPhone simulator and iOS device.
It's also working between Android emulator and Android device.
However, it is not working between android device and iOS device.
Can any one please suggest to me what I could be doing wrong?
Thanks in advance..
Update:
Messages are coming from Android device to iOS device, but not from iOS to android.
I used this for Android:
ConnectionConfiguration connConfig = new ConnectionConfiguration(testHost,portNumber);
connection = new XMPPConnection(connConfig);
connConfig.setSASLAuthenticationEnabled(true);
I used this for iOS:
XMPPJID *jid=[XMPPJID jidWithString:loginDetails.username];
password=loginDetails.password;
[[self xmppStream] setMyJID:jid];
NSError *error;
if (![[self xmppStream] connect:&error])
{
NSLog(@"Error connecting: %@", error);
return NO;
}
return YES;
if (allowSelfSignedCertificates)
{
[settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
}
if (allowSSLHostNameMismatch)
{
[settings setObject:[NSNull null] forKey:(NSString *)kCFStreamSSLPeerName];
}
else
{
// Google does things incorrectly (does not conform to RFC).
// Because so many people ask questions about this (assume xmpp framework is broken),
// I've explicitly added code that shows how other xmpp clients "do the right thing"
// when connecting to a google server (gmail, or google apps for domains).
NSString *expectedCertName = nil;
NSString *serverHostName = [sender hostName];
NSString *virtualHostName = [[sender myJID] domain];
if ([serverHostName isEqualToString:@"talk.google.com"])
{
if ([virtualHostName isEqualToString:@"gmail.com"])
expectedCertName = virtualHostName;
else
expectedCertName = serverHostName;
}
else
{
expectedCertName = serverHostName;
}
[settings setObject:expectedCertName forKey:(NSString *)kCFStreamSSLPeerName];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论