Am trying to implement sign in with apple on my ionic 3 project using the following plugin and wrapper
ionic cordova plugin add cordova-plugin-sign-in-with-apple
npm i --save @ionic-native/sign-in-with-apple
Implementation as described on the plugin docs
import { SignInWithApple, AppleSignInResponse, AppleSignInErrorResponse, ASAuthorizationAppleIDRequest } from '@ionic-native/sign-in-with-apple/ngx';
constructor(private signInWithApple: SignInWithApple) { }
this.signInWithApple.signin({
requestedScopes: [
ASAuthorizationAppleIDRequest.ASAuthorizationScopeFullName,
ASAuthorizationAppleIDRequest.ASAuthorizationScopeEmail
]
})
.then((res: AppleSignInResponse) => {
// https://developer.apple.com/documentation/signinwithapplerestapi/verifying_a_user
alert('Send token to apple for verification: ' + res.identityToken);
console.log(res);
})
.catch((error: AppleSignInErrorResponse) => {
alert(error.code + ' ' + error.localizedDescription);
console.error(error);
});
The following error is thrown during cordova ios build process
typescript: node_modules/@ionic-native/sign-in-with-apple/ngx/index.d.ts, line: 6
Initializers are not allowed in ambient contexts.
L5: export declare class ASAuthorizationAppleIDRequest {
L6: static readonly ASAuthorizationScopeFullName = 0;
L7: static readonly ASAuthorizationScopeEmail = 1;
Any help would be appreciated, thanks
tsc -v
Version 3.8.3
this work for me:
ionic cordova plugin add https://github.com/twogate/cordova-plugin-sign-in-with-apple.git
declare var cordova:any; // global
cordova.plugins.SignInWithApple.signin(
{ requestedScopes: [0, 1] },
function(response){
console.log(response)
alert(JSON.stringify(response))
},
function(err){
console.error(err)
console.log(JSON.stringify(err))
}
I hope this solution can help someone.
IMPORTANT --> Test in device
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With