Ionic 4 使用 Apple 登录

Dav*_*yan 3 sign ionic-framework

拜托,你能帮我吗?我想添加使用 ionic 4 登录但没有文档我只找到了这个https://www.npmjs.com/package/cordova-plugin-sign-in-with-apple但不知何故我无法使用。

非常感谢

Dav*_*yan 5


import { SignInWithApple, AppleSignInResponse, AppleSignInErrorResponse, ASAuthorizationAppleIDRequest } from '@ionic-native/sign-in-with-apple/ngx';


  constructor(private signInWithApple: SignInWithApple) { }


    this.signInWithApple.signin({
      requestedScopes: [
        ASAuthorizationAppleIDRequest.ASAuthorizationScopeFullName,
        ASAuthorizationAppleIDRequest.ASAuthorizationScopeEmail
      ]
    })
    .then((res: AppleSignInResponse) => {
      // https://developer.apple.com/documentation/signinwithapplerestapi/verifying_a_user
      alert('Send token to apple for verification: ' + res.identityToken);
      console.log(res);
    })
    .catch((error: AppleSignInErrorResponse) => {
      alert(error.code + ' ' + error.localizedDescription);
      console.error(error);
    });
Run Code Online (Sandbox Code Playgroud)