Ionic 2自动登录不适用于Android Nougat Ionic开发应用程序

问题描述 投票:1回答:1

我正在创建一个离子应用程序。我完成了登录和注册。我使用JWT并在登录页面上,它将检查身份验证,如果令牌不存在或来自服务器的不同令牌,它将不会被记录。这在Android Lollipop设备和iOS上的Ionic开发应用程序上运行时效果很好。但在Nougat版本中,这些方法无效。

在Login.ts中:

ionViewDidLoad() {
    console.log('ionViewDidLoad LoginPage');
    this.showLoader();
           //Check if already authenticated
           this.authService.checkAuthentication().then((res) => {
               console.log("Already authorized");
               this.loading.dismiss();
               this.navCtrl.setRoot(HomePage);
           }, (err) => {
               console.log("Not already authorized");
               this.loading.dismiss();
           });
  }


showLoader(){

           this.loading = this.loadingCtrl.create({
               content: 'Authenticating...'
           });

           this.loading.present();

       }

在Auth提供商:

checkAuthentication(){

       return new Promise((resolve, reject) => {

           //Load token if exists
           this.storage.get('token').then((value) => {

               this.token = value;
               console.log(this.token);
               let headers = new Headers();
               headers.append('Authorization', 'Bearer '+this.token);

               this.http.get('http://139.59.35.176/api/users/1', {headers: headers})
                   .subscribe(res => {
                       resolve(res);
                   }, (err) => {
                       reject(err);
                   });

           });        

       });

     }

在离子开发应用程序上运行时,我不知道如何获得控制台。也在这里加载屏幕

验证...

不是在牛轧糖Android手机中解雇。我在这里错过了什么?

angular ionic-framework ionic2
1个回答
0
投票

我在离子开发应用程序中也遇到了同样的问题。但在构建live apk后,我没有遇到这个问题。所以尝试构建你的apk。

© www.soinside.com 2019 - 2024. All rights reserved.