iOS XMPPフレームワークXMPPStream接続されていませんか?
-
21-12-2019 - |
質問
iOS上のXMPPFrameworkを使用してパブリックXMPPサーバーに接続しようとしています。アプリが
にロードされたときに接続を設定しました- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Set up XMPP stream
self.xmppStream = [[XMPPStream alloc] init];
[self.xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
self.xmppStream.hostName = @"jabber.web.id";
self.xmppStream.hostPort = 5222;
[self connect];
.
接続:
- (void)connect {
NSString *username = @"eric1234";
self.password = @"test123";
[self.xmppStream setMyJID:[XMPPJID jidWithString:username]];
NSError *error = nil;
if (![self.xmppStream oldSchoolSecureConnectWithTimeout:XMPPStreamTimeoutNone error:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
NSLog(@"%hhd", [self.xmppStream isConnected]);
}
.
、その後私の代議的方法:
- (void)xmppStreamDidConnect:(XMPPStream *)sender {
NSError *error = nil;
if (![self.xmppStream authenticateWithPassword:self.password error:&error]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't authenticate %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
[self.xmppStream sendElement:[XMPPPresence presence]];
}
.
xmppStreamDidConnectは呼び出されません。サーバー上のDesktop XMPPクライアントを使用して、Jabber.Web.IDでERIC1234を正常に登録した理由はわかりません。任意のアイデア?
解決
変更することでそれを修正しました:
NSString *username = @"eric1234@jabber.web.id";
. 他のヒント
9右のJID: それで、上記の問題で。
NSString *username = @"eric1234@domain_name"; (domain name may be diff. than hostname.)
. 所属していません StackOverflow