signInWithApple method
Future<User?>
signInWithApple(
)
Implementation
Future<User?> signInWithApple() async {
// final appleProvider = AppleAuthProvider();
try {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: 'com.wahyzdad.doThisForMe.service',
redirectUri: Uri.parse(
'https://do-this-for-me-ff993.firebaseapp.com/__/auth/handler',
// 'do-this-for-me-ff993.firebaseapp.com',
),
),
);
final appleOAuthCredential = OAuthProvider("apple.com").credential(
idToken: appleCredential.identityToken,
accessToken: appleCredential.authorizationCode,
);
// get credential part
final credential = await FirebaseAuth.instance
.signInWithCredential(appleOAuthCredential);
// final UserCredential credential;
// if (kIsWeb) {
// credential = await FirebaseAuth.instance.signInWithPopup(appleProvider);
// } else {
// credential =
// await FirebaseAuth.instance.signInWithProvider(appleProvider);
// }
User? user = credential.user;
// state = AsyncData(user.email);
return user;
} catch (e) {
debugPrint("[[Error on Riverpod signInWithApple]]: $e");
return null;
}
}