2016-01-06 7 views
6

का उपयोग करके लॉगिन करने में सक्षम हो सकता है मैं robbiehanson से XMPPFramework का उपयोग करके एक साधारण चैट एप्लिकेशन विकसित कर रहा हूं। मैंने अपने सिस्टम में eJabberd सर्वर स्थापित किया है और कुछ उपयोगकर्ताओं को बनाया है। मैंने होस्टनाम = "लोकलहोस्ट" सेट किया है और उस उपयोगकर्ता प्रमाण-पत्र के साथ लॉगिन करने का प्रयास किया है। यह सफलतापूर्वक लॉग इन है। जब मैं होस्टनाम यानी होस्टनाम = "talk.google.com" बदलता हूं। मैं लॉगिन करने में सक्षम नहीं हूँ। मैं "साइन करने का प्रयास रोका" मेल औरआईओएस: एक्सएमपीपी फ्रेमवर्क: जीमेल अकाउंट

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

हूँ मैं Google डेवलपर कंसोल में अनुप्रयोग रजिस्टर करने की आवश्यकता है? कृपया मुझे XMPPFramework में जीमेल खाते को एकीकृत करने का समाधान प्रदान करें।

+0

[यह जाँच] (http://stackoverflow.com/questions/22865340/gtalk-implementation-in-ios) –

+0

@the_UB मैं सके – Sridhar

+0

देखना टेक्स्ट पर क्लिक करें 'इसे जांचें' –

उत्तर

0

क्या आप वाकई अपना जेआईडी और होस्टनाम सही तरीके से सेट कर चुके हैं?

XMPPStream.h फ़ाइल में कुछ निर्देश हैं hostname संपत्ति से ऊपर।

आपको यह भी पता होना चाहिए कि एक्सएमपीपी पर 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

@ धन्यवाद UnknOwn.Bit, XMPPXOAuth2Google.m में किस प्रकार के बदलाव किए जाने की आवश्यकता है? – Sridhar

+0

क्या आपको कोई जवाब मिला? – Sagrian

+0

नहीं मुझे कोई जवाब नहीं मिला – Sridhar

संबंधित मुद्दे