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”.

1 Like

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))
}
)

3 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:

1 Like

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);
          }); */
    
    }
2 Likes

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

1 Like

Hello,

Hii…I am using ionic 3.19.0 and want to install @ionic-native/sign-in-with-apple@4 but it is saying no version found for that.

I have also used this but getting error like cordova.plugins not found.Please guide me.

my implementation for login with Apple ID works well with me ionic 3 using the fat function to call API out of scope succ function stackoverflow solution.