Sign In with apple for ionic 4

I found the solution

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);
});
4 Likes