Issue
I am using Capacitor sign in with apple to login with Apple, this is my code:
registerApple(apple: string) {
SignInWithApple.authorize().then(resp => {
this.loginSocial(resp);
console.log("respuesta", resp.response);
if (this.error === true) {
this.activateTabMenu(true);
this.navCtrl.navigateRoot("/home");
} else {
this.register(resp.response, resp.response.user, null, null);
this.user.socialType = apple;
this.viewMode = "view1";
this.progressValue = 0.3;
this.dataDepTp();
}
}).catch((err) => console.log(err));
}
the thing is that when I test it it doesn't work, the Apple GUI doesn't open, and the xcode console prints the next message:
[log] - {"code":"UNIMPLEMENTED"}
I also already enable the Sign In with Apple in xcode and apple developers
what can I do?
Solution
Run on physical device or on macOS, iOS has a few issues with this plugin - https://github.com/capacitor-community/apple-sign-in/issues/23
The following example is Capacitor 3/4 related
Signin with apple requires an options field with a nonce.
The example below uses firebase and npm sha.js
Have a look at the https://github.com/capacitor-community/apple-sign-in docs
Also, the Firebase Apple Sign-in Setup guide explains the apple email relay config - https://firebase.google.com/docs/auth/ios/apple?authuser=0&hl=en'
async loginApple() {
if (this.platform.is('capacitor')) {
const rawNonce = 'any random string will do here';
const nonce = shajs('sha256').update(rawNonce).digest('hex');
const options: SignInWithAppleOptions = {
clientId: 'com.example.app',
redirectURI: 'https://your-app-name.firebaseapp.com/__/auth/handler',
scopes: 'email name',
state: '123456',
nonce,
};
try {
const { response } = await SignInWithApple.authorize(options);
console.log('app:auth: loginApple response - ', response);
}
}
}
Answered By - Warren
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.