Sign in with Apple ID => Ionic Support?

I have several Ionic 3 apps that I’m starting to get worried about. As you know, Apple is saying April 2020 will be the deadline to support “Sign in with Apple ID”. Is there a solution in-place?

I can’t seem to find much documentation on it. Thank you in advance.

2 Likes

I have the same concern, please help.

Yes there is… firebase has this. https://firebase.googleblog.com/2019/11/sign-in-with-apple-auth.html

1 Like

You can use this plugin:
https://www.npmjs.com/package/cordova-plugin-sign-in-with-apple

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

Thanks Jay0, I’ll try it out.

Is this plugin working?

I have my app rejected by Apple because it has Google and Facebook logins and does not have Apple login. Tried this plugin but I am stuck with an error highlighting SignInWithApple on the function cordova.plugins.SignInWithApple.signin( ) saying “Property ‘SignInWithApple’ does not exist on type ‘CordovaPlugins’” I have declared cordova: any on the top of the page. Please assist. :frowning:

There is a similar topic created 9 hours before yours:

And there is an answer with the following plugin:

It seems most of us need some free and really working solution

Managed to get my Apple login to work. Here is what I have to do;

Added this line under the declarations;
import { GooglePlus } from ‘@ionic-native/google-plus’;

import { Facebook } from ‘@ionic-native/facebook’;

declare var cordova: any; //Add this line right below the imports

Then here is the function

doAppleLogin() {
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))
}
)
}

Please note: Test on simulator or ios device.

Thanks

Dave

2 Likes

Glad to help. :smiley:

Has anyone had success with passing the result to Firebase for authentication?
The only method they currently offer is a popup or native with a nonce passed to the credential as far as I can tell…

Any guidance would be appreciated.

2 Likes

you can use the coding here:

import { Component, OnInit } from '@angular/core';
import { Validators, FormBuilder, FormGroup, FormControl } from '@angular/forms';
import { AuthNativeService } from 'src/app/services/auth.native.service';
import { Router } from '@angular/router';
import { AngularFirestore } from '@angular/fire/firestore';
import { NavController, ToastController, Platform } from '@ionic/angular';
import { AngularFireAuth } from '@angular/fire/auth';
import { Facebook } from '@ionic-native/facebook/ngx';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import * as firebase from 'firebase/app';
declare var SignInWithApple: any;
////////

async appleLogin() {
const appleUser = await SignInWithApple.request({
    requestedScopes: [ SignInWithApple.Scope.Email, SignInWithApple.Scope.FullName ],
  })
  var appleProvider = new firebase.auth.OAuthProvider('apple.com')
  await this.afAuth.auth.signInWithCredential(appleProvider.credential(appleUser.identityToken)).then(res => console.log(res, 'risposta auth'))
  this.router.navigate(["/tabs/home"]);
  }
  catch(error) { console.log("ERROR: " +error) };
}

That’s what worked for me. Hope it helps!

it’s working for me :smiley:

There is a nice tutorial in Medium that is working for me

it’s working but i want to call my login data service under success

cordova.plugins.SignInWithApple.signin(
        { requestedScopes: [0, 1] },
        function(succ){
          console.log('succ');
          console.log(succ);
          this.DService.AuthUser(succ).then((res :any) => { /* this is not working under this function */
            console.log('Result');
            console.log(res);
          });
      });

it’s giving me following error

ERROR: Unhandled Promise rejection: null is not an object (evaluating ‘this.DService’) ; Zone: ; Task: Promise.then ; Value: TypeError: null is not an object (evaluating ‘this.DService’)

can any one help on this?