signInWithApple method
Future<UserCredential>
signInWithApple(
)
Implementation
Future<UserCredential> signInWithApple() async {
late UserCredential c;
final rawNonce = generateNonce();
final nonce = sha256ofString(rawNonce);
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
nonce: nonce,
);
final oauthCredential = OAuthProvider("apple.com").credential(
idToken: appleCredential.identityToken,
rawNonce: rawNonce,
);
c = await FirebaseAuth.instance.signInWithCredential(oauthCredential);
Map<String, dynamic> profile = c.additionalUserInfo?.profile ?? {};
String? firstName = appleCredential.givenName ??
profile["given_name"] ??
extractFirstName(c.user!);
String? lastName = appleCredential.familyName ??
profile["family_name"] ??
extractLastName(c.user!);
verbose("Apple First Name: $firstName");
verbose("Apple Last Name: $lastName");
svc<UserService>().grabName(firstName, lastName);
return c;
}