2016-01-06 6 views
6

Ich entwickle eine einfache Chat-Anwendung mit XMPPFramework von robbiehanson. Ich habe eJabberd Server in meinem System installiert und einige Benutzer erstellt. Ich setze hostname = "localhost" und versuchte mich mit diesen Benutzeranmeldeinformationen anzumelden. Es wurde erfolgreich angemeldet. Wenn ich den Hostnamen ändere, zB hostname = "talk.google.com". Ich kann mich nicht anmelden. Ich habe "Anmeldeversuch verhindert" Mail undiOS: XMPPFramework: Kann mich nicht mit Gmail-Konto anmelden

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

FYI,

- (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; 
} 

Bin ich App in Google Developer Console registrieren? Bitte geben Sie mir die Lösung, um Gmail-Konto in das XMPPFramework zu integrieren.

+0

[überprüfen it] (http://stackoverflow.com/questions/22865340/gtalk-implementation-in-ios) –

+0

@the_UB Ich sehe – Sridhar

+0

könnte nicht:

einige Standard Änderungen von XMPPFramework getan werden Klicke auf den Text 'check it' –

Antwort

0

Sind Sie sicher, dass Sie Ihre JID und Ihren Hostnamen richtig eingestellt haben?

Es gibt einige Anweisungen in XMPPStream.h Datei knapp über hostname Eigentum.

Sie sollten auch wissen, dass Konfigurationen für Google-Server auf XMPP ein wenig unterscheidet, Stellen Sie sicher, erforderliche Konfigurationen innerhalb XMPPXOAuth2Google.m Datei und auch innerhalb goOnline Methode auf Delegate getan werden.

- (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, Welche Art von Änderungen müssen in XMPPXOAuth2Google.m vorgenommen werden? – Sridhar

+0

Hast du eine Antwort bekommen? – Sagrian

+0

nein ich habe keine Antworten bekommen – Sridhar