flutter integrated apple login

1. Import package

sign_in_with_apple: ^3.0.0

2.ios related configuration

In the Apple Developer Center, click on Identifiers under Certificates, Identifiers & Profiles, and check Sign in with Apple

In xcode, click in turn: left root directory Runner--"Runner under TARGETS--"Signing & Capabilities--"Add Sign in with Apple

3. Code

GestureDetector(
    onTap: () async {
        final credential = await SignInWithApple.getAppleIDCredential(
            scopes: [
                AppleIDAuthorizationScopes.email,
                AppleIDAuthorizationScopes.fullName,
            ],
        );
        if (credential != null) {
            // appleLogin为apple登录逻辑
            appleLogin(credential.identityToken);
        }
    },
)

Guess you like

Origin blog.csdn.net/YML_426/article/details/129855233