signInWithApple method
Implementation
Future<UserAuthInfo?> signInWithApple(TypeLogin typeLogin) async {
// To prevent replay attacks with the credential returned from Apple, we
// include a nonce in the credential request. When signing in with
// Firebase, the nonce in the id token returned by Apple, is expected to
// match the sha256 hash of `rawNonce`.
final rawNonce = generateNonce();
final nonce = sha256ofString(rawNonce);
// Request credential for the currently signed in Apple account.
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
nonce: nonce,
);
if (appleCredential.userIdentifier != null) {
var email = appleCredential.email ?? getEmailFromAppleIdToken(appleCredential.identityToken.toString());
return UserAuthInfo(
id: appleCredential.userIdentifier!, typeLogin: typeLogin, email: email, name: appleCredential.familyName);
} else {
return null;
}
}