How To Add Sign In With Apple In Ionic 3

Hi,
Anybody knows how i can add “Sign In With Apple” in ionic 3 ios application as apple is rejecting apps having any third party login but not having “Sign In With Apple”.

Firebase has that option. https://firebase.googleblog.com/2019/11/sign-in-with-apple-auth.html

1 Like

You can use this plugin:

Usage:
declare var cordova: any;

cordova.plugins.SignInWithApple.signin(
null,
(appleLoginResponse: any) => {
console.log( appleLoginResponse )
this.signInFirebaseApple( appleLoginResponse )
},
(err: any) => {
console.error(err)
console.log(JSON.stringify(err))
}
)

2 Likes

Thanks, that workaround works well for now :tada: . I hope the Apple review will be good this time. :sweat_smile:

1 Like

Hi,

Please, could you help me, after install plugin, SignInWithApple not recognize.

Many Thanks

Show error like this, Property ‘SignInWithApple’ does not exist on type ‘CordovaPlugins’.

Is it possible to force user to share his email address?

cordova.plugins.SignInWithApple.signin(
      { requestedScopes: [0, 1] },
      function(succ) {
        console.log(succ)
        alert(JSON.stringify(succ))
      },
      function(err){
        console.error(err)
        console.log(JSON.stringify(err))
      }
    )

I setted requested scopes to 0,1. 1 is email address but email is for me mandatory. User can optionally share the email during authentication process

Thanks
L

@lsantaniello I think this not possible. Please refer to the plugins documentation: https://www.npmjs.com/package/cordova-plugin-sign-in-with-apple. Also check Apple’s officlal documentation about Apple Login: https://www.npmjs.com/package/cordova-plugin-sign-in-with-apple

1 Like

Works ! tks :slight_smile:

There is a wrapper available for Apple Signin at https://www.npmjs.com/package/@ionic-native/sign-in-with-apple

$ ionic cordova plugin add cordova-plugin-sign-in-with-apple
$ npm install @ionic-native/sign-in-with-apple
if (this.platform.is('ios')) {

        const appleCredential: AppleSignInResponse = await SignInWithApple.signin({
          requestedScopes: [
            ASAuthorizationAppleIDRequest.ASAuthorizationScopeFullName,
            ASAuthorizationAppleIDRequest.ASAuthorizationScopeEmail
          ]
        });

         // If you're using firebase authentication
        /* const credential = new firebase.auth.OAuthProvider('apple.com').credential(
          appleCredential.identityToken
        );
        this.afAuth.auth.signInWithCredential(credential)
          .then((res) => {
            console.log('Login successful', res);
          })
          .catch((error) => {
            console.log(error);
          }); */
    
    }
1 Like

I just created a medium article explaning how! :slight_smile: feel free to have a look