Пример, если вы также используете Firebase
Установить собственный плагин
npm i --save @ionic-native/sign-in-with-apple
В вашем приложении
import {
SignInWithApple,
AppleSignInResponse,
AppleSignInErrorResponse,
ASAuthorizationAppleIDRequest
} from '@ionic-native/sign-in-with-apple';
constructor(private afAuth: AngularFireAuth) {}
async nativeAppleAuth(): Promise<void> {
try {
const appleCredential: AppleSignInResponse = await SignInWithApple.signin({
requestedScopes: [
ASAuthorizationAppleIDRequest.ASAuthorizationScopeFullName,
ASAuthorizationAppleIDRequest.ASAuthorizationScopeEmail
]
});
const credential = new firebase.auth.OAuthProvider('apple.com').credential(
appleCredential.identityToken
);
const response = await this.afAuth.auth.signInWithCredential(credential);
console.log('Login successful', response);
} catch (error) {
console.log(error);
}
}