signInWithApple method

Future<UserCredential?> signInWithApple()

Implementation

Future<UserCredential?> signInWithApple() async {
  //get generated nonce
  final rawNonce = _generateNonce();
  //encrypt nonce
  final nonce = _sha256ofString(rawNonce);
  //initialize apple credential
  final AuthorizationCredentialAppleID appleCredential =
      await SignInWithApple.getAppleIDCredential(
    scopes: [
      //set scopes
      AppleIDAuthorizationScopes.email,
      AppleIDAuthorizationScopes.fullName,
    ],
    nonce: nonce,
  );
  //set credential
  final oauthCredential = OAuthProvider("apple.com").credential(
    idToken: appleCredential.identityToken,
    rawNonce: rawNonce,
  );

  //sign in with credential
  return await Utils().signInWithCredential(oauthCredential);
}