Just had the same problem as you and spent quite a few hours to figure this out but finally got it working using Ionic 4/Angular and Angularfire by using this plugin: cordova-plugin-apple-login
Note that there is no Ionic Native wrapper for the plugin, so you have to declare it instead of importing it:
declare var SignInWithApple: any;
This is the login function:
loginWithApple() {
SignInWithApple.request({requestedScopes: [ SignInWithApple.Scope.Email, SignInWithApple.Scope.FullName ]})
.then((appleCredential) => {
const credential = new firebase.auth.OAuthProvider('apple.com').credential(appleCredential.identityToken);
this.afAuth.auth.signInWithCredential(credential)
.then((response) => {
console.log('Login successful');
})
.catch((error) => {
console.log(error);
});
});
}
Note that you also have to do some config:
- Xcode: Add capability for Sign in with Apple
- Apple Developer: Add Services id
- Firebase console (Add Sign-in method for Apple, leave all fields blank if you only use on iOS)
Hope this helps!