Ionic 电容器签入用苹果不工作

ohfgkhjo  于 2022-12-08  发布在  Ionic
关注(0)|答案(1)|浏览(174)

我使用电容器登录与苹果登录与苹果,这是我的代码:

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

问题是,当我测试它时,它不工作,Apple GUI不打开,xcode控制台打印下一条消息:

[log] - {"code":"UNIMPLEMENTED"}

我还在xcode和apple开发者中启用了“登录Apple”
我能做什么呢?

ukqbszuj

ukqbszuj1#

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

相关问题