Recupero delle informazioni del profilo in corso...

Dopo che un utente ha eseguito l'accesso con Google, puoi ottenere il suo profilo di base informazioni: nome, URL dell'immagine del profilo e indirizzo email.

Prima di iniziare

Recupero delle informazioni dell'utente

Dopo che l'utente avrà autenticato e autorizzato l'accesso agli ambiti da te richiesti, puoi accedere alle informazioni del profilo utente tramite l'oggetto 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];
}];