Ionic-native: "requestPermissions" in Android Permissions is not working

Created on 17 May 2017  路  4Comments  路  Source: ionic-team/ionic-native

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:
1. I have the below code in my component

 this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_SMS).then(
              success => {  console.log('Permission granted');  }
              err => { console.log('Error'); }
            );

Throwing error: "TypeError: Cannot read proerty 'READ_SMS' of undefined".
Please see the SS below.
image

2. I have the below code in my component
this.androidPermissions.requestPermissions("android.permission.READ_SMS");

Throwing error: "JSON error".
Please see the SS below.
image

Most helpful comment

 this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]).then(
    success => {
      this.presentToast("Has permission?  "+ success,"toast-warning")


    },
    err => this.androidPermissions.requestPermissions(this.androidPermissions.PERMISSION.CAMERA)
  );

All 4 comments

Regarding the first issue, the PERMISSION object was defined incorrectly. I just fixed it and it should work well in the next release.

As for the second issue, the function requestPermissions takes an array of strings, not a single string. The typescript definition is incorrect. I fixed this as well and added requestPermission method to request a single permission.

Thanks a lot. When can I expect the next release?
May I know your file changes? So that I can update my local code and continue my development.
Thanks again :)

Have a look at https://github.com/driftyco/ionic-native/commit/ebf402864bda19fc1c937a71c3bcdd4d6c8bdff2

I will publish a release soon once I review some more issues.

 this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]).then(
    success => {
      this.presentToast("Has permission?  "+ success,"toast-warning")


    },
    err => this.androidPermissions.requestPermissions(this.androidPermissions.PERMISSION.CAMERA)
  );
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Manduro picture Manduro  路  3Comments

GunaSekhar1 picture GunaSekhar1  路  4Comments

mateo666 picture mateo666  路  3Comments

icchio picture icchio  路  3Comments

christianwico picture christianwico  路  4Comments