Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Sign in with apple failure

i implement sign in with apple on my apps, for some reason my server return error cause username length from sign in with apple didn't meet my condition and i didn't cache the information of the user. After that i update the server to remove username length requirement, but unfortunately user name and email is null? The solution i know is to stop using apple id from setting page on Iphone, is there any other solution from code? here is my code :

AppleSignInButton(
  style: ButtonStyle.whiteOutline,
  cornerRadius: 8,
  type: ButtonType.signIn,
  onPressed: () async {
    var isConnected = await checkConnection();
    if (!isConnected) {
        showErrorDialog(message: ErrorMessage.NO_NETWORK);
    } else {
        final AuthorizationResult result = await AppleSignIn.performRequests([
                AppleIdRequest(requestedScopes: [Scope.email, Scope.fullName])
        ]);

        if (result != null) {
            switch (result.status) {
                case AuthorizationStatus.authorized:
                    _loginWithApple(result.credential);
                    break;
                case AuthorizationStatus.cancelled:
                    break;
                case AuthorizationStatus.error:
                    showErrorDialog(message: result.error.localizedFailureReason);
                    break;
            }
        } else {
            showErrorDialog(message: result.status.toString(), onTap: (){});
        }
    }
},)
like image 860
MNFS Avatar asked Oct 12 '25 13:10

MNFS


1 Answers

Apparently Apple provides the fullName and email fields for the first sign in only. These fields will be null for subsequent sign ins.

However, you may opt to get the fullName through appleIDCredential.fullName in didCompleteWithAuthorization delegate method, and update the user's profile yourself.

Source: https://github.com/firebase/firebase-ios-sdk/issues/4393#issuecomment-559012512

like image 128
Twyx Avatar answered Oct 14 '25 04:10

Twyx