Ich habe dieses Tutorial auf Medium, dieses Tutorial auf Firebase-Seite und diese Paket-Readme-Datei verfolgt und angeschaut.
Aktivierte Apple-Anmeldung für die App im Bezeichner. Service-ID erstellt. Erstellter Schlüssel. Alles auf der Firebase-Seite ausgefüllt (Apple-Team-ID, Schlüssel-ID, privater Schlüssel). Wird als Rückgabe-URL „[FIREBASE_APPLE_SIGN_IN_RETURN_URL]“ (von FireBase bereitgestellt) ausgefüllt.
Unter IOS funktioniert es einwandfrei, aber das passiert, wenn ich versuche, mich beim Android-Emulator anzumelden:
- Ich klicke auf „Mit Apple anmelden“
- Ich werde zu Apple weitergeleitet (appleid.apple.com)
- I Geben Sie meine ID und mein Passwort ein und klicken Sie auf „Weiter“.
- Apple fragt mich, ob ich sicher bin und fortfahren möchte. Ich klicke auf „Weiter“
- Ich erhalte die Fehlermeldung:
passieren, wenn der Browser-SessionStorage nicht zugänglich ist oder versehentlich
geleert wurde. Einige spezifische Szenarien sind: 1) Verwendung von IDP-initiiertem SAML
SSO. 2) Verwendung von signInWithRedirect in einer speicherpartitionierten Browserumgebung.
Mein SignInCode:
Code: Select all
/// Sign In With Apple
signInWithApple() async {
try {
String clientID = 'com.example-service'; /// same ID like in the service ID, com.example is a placeholder
String redirectURL = '[FIREBASE_APPLE_SIGN_IN_RETURN_URL]'; /// Here I have the URL and this is just a placeholder
/// Generates a Random String from 1-9 and A-Z characters.
final rawNonce = generateNonce();
/// We are convering that rawNonce into SHA256 for security purposes
/// In our login.
final nonce = sha256ofString(rawNonce);
final appleCredential = await SignInWithApple.getAppleIDCredential(
/// Scopes are the values that you are requiring from
/// Apple Server.
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
nonce: Platform.isIOS ? nonce : null,
/// We are providing Web Authentication for Android Login,
/// Android uses web browser based login for Apple.
webAuthenticationOptions: Platform.isIOS
? null
: WebAuthenticationOptions(
clientId: clientID,
redirectUri: Uri.parse(redirectURL),
),
);
final AuthCredential appleAuthCredential = OAuthProvider('apple.com').credential(
idToken: appleCredential.identityToken,
rawNonce: Platform.isIOS ? rawNonce : null,
accessToken: Platform.isIOS ? null : appleCredential.authorizationCode,
);
/// Once you are successful in generating Apple Credentials,
/// We pass them into the Firebase function to finally sign in.
UserCredential result = await _auth.signInWithCredential(appleAuthCredential);
User? user = result.user;
/// Check everything is ok and user is not null
if (user != null) {
if (result.additionalUserInfo!.isNewUser) {
await user.delete();
signOut();
return Strings.youHaveToSignUpbeforeSignInWithApple;
}
return _userFromFireBaseUser(user);
}
return null;
} catch (e) {
rethrow;
}
}