1.引入包
sign_in_with_apple: ^3.0.0
2.ios相关配置
在apple开发者中心点击Certificates, Identifiers & Profiles下的Identifiers,勾选Sign in with Apple
在xcode中依次点击:左侧根目录Runner--》TARGETS下的Runner--》Signing & Capabilities--》添加Sign in with Apple
3.代码
GestureDetector(
onTap: () async {
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
if (credential != null) {
// appleLogin为apple登录逻辑
appleLogin(credential.identityToken);
}
},
)