פרטי הפרופיל מתקבלים

אחרי שמשתמש נכנס באמצעות חשבון Google, אתם יכולים לראות את הפרופיל הבסיסי של המשתמש. פרטים: השם, כתובת ה-URL של תמונת הפרופיל וכתובת האימייל שלהם.

לפני שמתחילים

מתבצע אחזור של פרטי המשתמש

אחרי שהמשתמש אימת ויאשר גישה להיקפים שאתם מבקשים, אפשר לגשת לפרטי פרופיל המשתמש באמצעות האובייקט GIDGoogleUser.

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)
}
[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];
}];