gurisko / cordova-plugin-accountkit

AccountKit Plugin for Apache Cordova which allows you to add passwordless email and SMS authentication to your app
MIT License
34 stars 42 forks source link

Ionic: AccountKitPlugin.getAccount error : Server generated an error #51

Open lilian131 opened 6 years ago

lilian131 commented 6 years ago

hello it is working good on ios but I get the error on android when executing AccountKitPlugin.getAccount Server generated an error no more please look at my code is there something to do to correct this code

phonelogin(){
    if (this.registerNum.length === 10) {
    localStorage.setItem('phone',this.registerNum);

      (<any>window).AccountKitPlugin.loginWithPhoneNumber({
            initialPhoneNumber: ["+966", this.registerNum],
            useAccessToken: true,
            defaultCountryCode: "SA",
            facebookNotificationsEnabled: true
          }, (successdata) => {
              (<any>window).AccountKitPlugin.getAccount((user) => {
                  this.tok = user;
                  this.presentLoader();
                  this.loginService.sendTokenToAPI(successdata)
                  .subscribe((user: any) => {
                        localStorage.setItem('token', "bearer " + user.token);
                        if (this.navParams.get("flag") == 0) {
                          this.navCtrl.setRoot("CartPage");
                        } else{
                          this.navCtrl.setRoot("HomePage");
                          this.socketService.establishConnection();
                          this.renderImage();
                          this.showToaster("User Successfully logged in !", 5000);
                        }
                        this.loader.dismiss();
                  }, (error) => {
                    this.loader.dismiss();
                    console.log(error);
                     if (error.error instanceof Error) {
                        alert('Client-side error occured.');
                     } else {
                      console.log(error);
                      this.message = error.stack;               
                        this.message = {message: this.message, str: this.message}                  
                        console.error(JSON.parse(this.message));                                                
                        console.error(error.message );

                    }
                  });
              }, (err) => {
                console.log("err");
                console.log(err);
                console.log("err");
              });
          }, (err) => {
            alert(err);
          })
    } else if ((this.registerNum.length < 10 || this.registerNum.length > 10) && this.registerNum.length > 0) {
        this.showToaster("the number format is not correct", 3000);
    } else if (this.registerNum.length === 0) {
        this.showToaster("please enter your phone number to login", 3000);
    }
  }
hadoanngoc commented 6 years ago

I have some error. Don't know how to get back user mobile number after authorization except calling .getAccount()

But it generates "Server generated an error" message