Ionic-native: Build Error About Sign In With Apple In Ionic 3

Created on 1 Jul 2020  路  6Comments  路  Source: ionic-team/ionic-native

I'm submitting a ... (check one with "x")
[x] bug report

Current behavior:
Build Error after installed Sing In With Apple

ionic cordova prepare ios

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;

[12:59:29] typescript: node_modules/@ionic-native/sign-in-with-apple/ngx/index.d.ts, line: 7
Initializers are not allowed in ambient contexts.

   L6:  static readonly ASAuthorizationScopeFullName = 0;
   L7:  static readonly ASAuthorizationScopeEmail = 1;
   L8:  requestedScopes?: number[];

After commend line those lines and call plugin with

....signin({
requestedScopes: [0, 1]
})

no error while prepare or building.
But after that the pop-up should appear for email and name doesn't show up.

Expected behavior:
Email and name pop up should appear.

Other information:
I opened issue in plugins repo but they told me to open issue to ionic natives repo because it is not relevant with ours plugin.

I tried to do exactly like here but nope. In ionic 3 there is an error.

Ionic info:

```
Ionic:

Ionic CLI : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : ionic-angular 3.9.9
@ionic/app-scripts : 3.2.4

Cordova:

Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 5 other plugins)

Utility:

cordova-res : 0.15.1
native-run : 1.0.0

System:

ios-deploy : 1.10.0
ios-sim : 8.0.2
NodeJS : v12.18.0 (/usr/local/bin/node)
npm : 6.14.5
OS : macOS Catalina
Xcode : Xcode 11.5 Build version 11E608c```

Most helpful comment

Getting the same error.
The error comes from the small changes in this commit.

Using the version before that commit solved the problem for me. If you're ok with reverting to a previous version, try this:

npm install @ionic-native/[email protected]

After that ionic build should succeed. Good luck!

All 6 comments

I'm submitting a ... (check one with "x")
[x] bug report

Current behavior:
Build Error after installed Sing In With Apple

ionic cordova prepare ios

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;

[12:59:29] typescript: node_modules/@ionic-native/sign-in-with-apple/ngx/index.d.ts, line: 7
Initializers are not allowed in ambient contexts.

   L6:  static readonly ASAuthorizationScopeFullName = 0;
   L7:  static readonly ASAuthorizationScopeEmail = 1;
   L8:  requestedScopes?: number[];

After commend line those lines and call plugin with

....signin({
requestedScopes: [0, 1]
})

no error while prepare or building.
But after that the pop-up should appear for email and name doesn't show up.

Expected behavior:
Email and name pop up should appear.

Other information:
I opened issue in plugins repo but they told me to open issue to ionic natives repo because it is not relevant with ours plugin.

I tried to do exactly like here but nope. In ionic 3 there is an error.

Ionic info:

Ionic:

   Ionic CLI          : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework    : ionic-angular 3.9.9
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 9.0.0 ([email protected])
   Cordova Platforms : ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 5 other plugins)

Utility:

   cordova-res : 0.15.1
   native-run  : 1.0.0

System:

   ios-deploy : 1.10.0
   ios-sim    : 8.0.2
   NodeJS     : v12.18.0 (/usr/local/bin/node)
   npm        : 6.14.5
   OS         : macOS Catalina
   Xcode      : Xcode 11.5 Build version 11E608c```

谋 also have same issue pls help

I tried your solution and faced the same issues with me.

my implementation for login with Apple ID works well with me ionic 3.

ionic cordova plugin add cordova-plugin-sign-in-with-apple

//before @component add declare var cordova: any;

        async loginWithAppleID() {
        await cordova.plugins.SignInWithApple.signin(
          {requestedScopes: [0, 1]},
          (succ) => {
            //get email and full name from Apple ID
            console.log(succ)
            let userData = {
              name: succ.fullName.givenName + ' ' + succ.fullName.familyName,
              email: succ.email,
            };
    // this.AuthApi;
          },
          (err) => {
            console.error(err)
            console.log(JSON.stringify(err))
          }
        )
      }

@AmrAlmagic

Hello, I solved my problem but when I execute the function I do not get anything, it works in simulator?

thanks.

@AmrAlmagic

Hello, I solved my problem but when I execute the function I do not get anything, it works in simulator?

thanks.

yes, it works in the simulator.

Getting the same error.
The error comes from the small changes in this commit.

Using the version before that commit solved the problem for me. If you're ok with reverting to a previous version, try this:

npm install @ionic-native/[email protected]

After that ionic build should succeed. Good luck!

I tried your solution and faced the same issues with me.

my implementation for login with Apple ID works well with me ionic 3.

ionic cordova plugin add cordova-plugin-sign-in-with-apple

//before @component add declare var cordova: any;

        async loginWithAppleID() {
        await cordova.plugins.SignInWithApple.signin(
          {requestedScopes: [0, 1]},
          (succ) => {
            //get email and full name from Apple ID
            console.log(succ)
            let userData = {
              name: succ.fullName.givenName + ' ' + succ.fullName.familyName,
              email: succ.email,
            };
    // this.AuthApi;
          },
          (err) => {
            console.error(err)
            console.log(JSON.stringify(err))
          }
        )
      }

Hello, may I know what is the meaning of those two comments? For the first, is it we inserted by ourself or getting it from apple? It seems like getting from apple but how? And the second is this.AuthApi. May I know what is it? Thank you..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ihadeed picture ihadeed  路  4Comments

ajcrites picture ajcrites  路  3Comments

GunaSekhar1 picture GunaSekhar1  路  4Comments

mateo666 picture mateo666  路  3Comments

wwallace picture wwallace  路  4Comments