I used sign_in_with_apple: ^4.3.0 package to appleID signin this is the latest version for the appleID signin
I couldn't find any documentations how to use this version without package example code. referring that example I tried a code
Future<void> signInWithApple() async {
try {
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
]);
// Get the OAuth token and ID Token
final AuthCredential authCredential =
OAuthProvider("apple.com").credential(
accessToken: String.fromCharCodes(credential.authorizationCode),
idToken: String.fromCharCodes(credential.identityToken));
// Signing in to firebase user instance
final UserCredential userCredential =
await FirebaseAuth.instance.signInWithCredential(authCredential);
// Update the user properties in the provider
_email = userCredential.user?.email;
_uid = userCredential.user?.uid;
_displayName = userCredential.user?.displayName;
notifyListeners();
} catch (e) {
// Handle the error
print(e);
_hasError = true;
_errorCode = e.toString();
notifyListeners();
}
}
in this code show these errors..
how to resolve these errors and signin to app using appleID
You can't use String.fromCharCodes
on a String value, also credential.authorizationCode
and credential.identityToken
are String values so you don't have to convert them.
Try to replace this
OAuthProvider("apple.com").credential(
accessToken: String.fromCharCodes(credential.authorizationCode),
idToken: String.fromCharCodes(credential.identityToken));
with this
OAuthProvider("apple.com").credential(
accessToken: credential.authorizationCode,
idToken: credential.identityToken);