2016-01-06 10 views
6

XMPPFrameworkを使用して簡単なチャットアプリケーションを1つ開発しています(robbiehanson)。私はeJabberdサーバを私のシステムにインストールして、いくつかのユーザーを作成しました。 hostname = "localhost"と設定し、そのユーザーの資格情報でログインしようとしました。正常にログインしています。ホスト名を変更すると、ホスト名= "talk.google.com"となります。私はログインできません。私はFYI、iOS:XMPPFramework:Gmailアカウントを使用してログインできます

- (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 = @"[email protected]/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のデベロッパーコンソールにアプリを登録する必要がアムメールを "サインインの試行を防ぐ" しまったと

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized></not-authorized></failure>

? XMPPFrameworkにGmailアカウントを統合するソリューションを教えてください。

+0

[それをチェック](http://stackoverflow.com/questions/22865340/gtalk-implementation-in-ios)私は –

+0

@the_UBテキストをクリックしてください。それを確認してください。 – Sridhar

+0

を参照してくださいcouldntの –

答えて

0

JIDとホスト名を正しく設定してもよろしいですか?

XMPPStream.hファイルには、hostnameの直上にいくつかの指示があります。

また、XMPP上のGoogleサーバーの設定は少し異なります。必要な設定がXMPPXOAuth2Google.mファイル内で行われていることと、代理人のgoOnlineメソッド内で実行されていることを確認する必要があります。

いくつかのデフォルトの変更はXMPPFrameworkによって行われます:

- (void)goOnline 
{ 
    XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit 

    NSString *domain = [xmppStream.myJID domain]; 

    //Google set their presence priority to 24, so we do the same to be compatible. 

    if([domain isEqualToString:@"gmail.com"] || 
     [domain isEqualToString:@"gtalk.com"] || 
     [domain isEqualToString:@"talk.google.com"]) 
    { 
     NSXMLElement *priority = [NSXMLElement elementWithName:@"priority" stringValue:@"24"]; 
     [presence addChild:priority]; 
    } 

    [[self xmppStream] sendElement:presence]; 
} 
+0

@Thanks UnknOwn.Bit、XMPPXOAuth2Google.mではどのような変更が必要ですか? – Sridhar

+0

答えはありますか? – Sagrian

+0

いいえ、私は答えを得られませんでした – Sridhar

関連する問題