2016-01-06 16 views
6

Sto sviluppando una semplice applicazione di chat utilizzando XMPPFramework da robbiehanson. Ho installato il server eJabberd nel mio sistema e ho creato alcuni utenti. Ho impostato hostname = "localhost" e ho provato ad accedere con le credenziali dell'utente. È stato effettuato correttamente il login. Quando cambio il nome host, ad esempio hostname = "talk.google.com". Non riesco ad accedere. Ho "tentativo di Sign-in ha impedito" posta eiOS: XMPPFramework: impossibile accedere utilizzando l'account gmail

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

am Ho bisogno di registrarmi app in Google Console per gli sviluppatori? Gentilmente forniscimi la soluzione per integrare l'account Gmail in XMPPFramework.

+0

[verificarlo] (http://stackoverflow.com/questions/22865340/gtalk-implementation-in-ios) –

+0

@the_UB non potevo vedere – Sridhar

+0

clicca sul testo 'check it' –

risposta

0

Sei sicuro di aver impostato correttamente JID e nome host?

Ci sono alcune istruzioni nel file XMPPStream.h appena sopra la proprietà hostname.

È inoltre necessario sapere che le configurazioni per i server Google su XMPP differiscono leggermente, Assicurarsi che le configurazioni richieste siano eseguite all'interno del file XMPPXOAuth2Google.m e anche all'interno del metodo goOnline su delegato.

Alcune modifiche di default sono fatto da 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, che tipo di modifiche devono essere fatte in XMPPXOAuth2Google.m? – Sridhar

+0

Hai ricevuto una risposta? – Sagrian

+0

no non ho avuto risposte – Sridhar