我正在使用robbiehanson的XMPPFramework开发一个简单的聊天应用程序.我在我的系统中安装了eJabberd服务器并创建了一些用户.我设置hostname ="localhost"并尝试使用该用户凭据登录.它已成功登录.当我更改主机名即hostname ="talk.google.com"时.我无法登录.我收到了"登录尝试被阻止"的邮件和
仅供参考,
- (BOOL)connectWithUsername:(NSString*)username WithPassword:(NSString*)pwd { if (![xmppStream isDisconnected]) { return YES; } // NSString *myJID = [[NSUserDefaults standardUserDefaults] stringForKey:kXMPPmyJID]; //NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:kXMPPmyPassword]; NSString* myJID=username; NSString* myPassword=pwd; // // If you don't want to use the Settings view to set the JID, // uncomment the section below to hard code a JID and password. // // Replace me with the proper JID and password: // myJID = @"user@gmail.com/xmppframework"; // myPassword = @""; if (myJID == nil || myPassword == nil) { NSLog(@"JID and password must be set before connecting!"); return NO; } [xmppStream setMyJID:[XMPPJID jidWithString:myJID]]; password = myPassword; NSError *error = nil; if (![xmppStream connectWithTimeout:100 error:&error]) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting" message:@"See console for error details." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alertView show]; NSLog(@"Error connecting: %@", error); return NO; } [self goOnline]; return YES; }
我需要在Google Developer Console中注册应用吗?请向我提供在XMPPFramework中集成Gmail帐户的解决方案.