जब कोई उपयोगकर्ता Google से साइन इन करता है, तो आपको उपयोगकर्ता की प्रोफ़ाइल की बुनियादी जानकारी मिलती है. जैसे, उसका नाम, प्रोफ़ाइल इमेज का यूआरएल, और ईमेल पता.
शुरू करने से पहले
- डिपेंडेंसी डाउनलोड करना और अपना Xcode प्रोजेक्ट कॉन्फ़िगर करना.
- अपने ऐप्लिकेशन में 'Google साइन इन' को इंटिग्रेट करना.
उपयोगकर्ता की जानकारी हासिल की जा रही है
जब उपयोगकर्ता, पुष्टि किए गए स्कोप के लिए, ऐक्सेस और पुष्टि कर लेता है, तो आप GIDGoogleUser
ऑब्जेक्ट की मदद से उपयोगकर्ता की प्रोफ़ाइल की जानकारी ऐक्सेस कर सकते हैं.
Swift
GIDSignIn.sharedInstance.signIn(withPresenting: self) { signInResult, error in
guard error == nil else { return }
guard let signInResult = signInResult else { return }
let user = signInResult.user
let emailAddress = user.profile?.email
let fullName = user.profile?.name
let givenName = user.profile?.givenName
let familyName = user.profile?.familyName
let profilePicUrl = user.profile?.imageURL(withDimension: 320)
}
Objective-C
[GIDSignIn.sharedInstance signInWithPresentingViewController:self
completion:^(GIDSignInResult * _Nullable signInResult,
NSError * _Nullable error) {
if (error) { return; }
if (signInResult == nil) { return; }
GIDGoogleUser *user = signInResult.user;
NSString *emailAddress = user.profile.email;
NSString *name = user.profile.name;
NSString *givenName = user.profile.givenName;
NSString *familyName = user.profile.familyName;
NSURL *profilePic = [user.profile imageURLWithDimension:320];
}];