1. Pacote de importação
sign_in_with_apple: ^3.0.0
2.ios configuração relacionada
No Apple Developer Center, clique em Identificadores em Certificados, Identificadores e Perfis e marque Entrar com a Apple
No xcode, clique em: diretório raiz esquerdo Runner--"Runner sob TARGETS--"Signing & Capabilities--"Add Sign in with Apple
3. Código
GestureDetector(
onTap: () async {
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
if (credential != null) {
// appleLogin为apple登录逻辑
appleLogin(credential.identityToken);
}
},
)