signIn method
Request credential for the currently signed in Apple account.
Implementation
@override
Future<SocialSignInResultInterface> signIn(BuildContext context) async {
stateCode = generateString(10); // simple state code
final rawNonce = generateNonce();
final nonce = sha256ofString(rawNonce);
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: scopes,
nonce: nonce,
state: buildState(),
webAuthenticationOptions: Platform.isAndroid
? WebAuthenticationOptions(
clientId: clientId,
redirectUri: Uri.parse(redirectUrl),
)
: null,
);
if (appleCredential.identityToken != null) {
return AppleSignInResult(SignInResultStatus.ok,
state: stateCode,
nonce: rawNonce,
idToken: appleCredential.identityToken!);
} else {
return AppleSignInResult(
SignInResultStatus.cancelled,
);
}
}