NathanaelA / nativescript-permissions

Wraps up the entire Android 6 permissions system in a easy to use plugin.
MIT License
46 stars 22 forks source link

WRITE_SETTINGS permission #35

Closed nikolasdas closed 5 years ago

nikolasdas commented 5 years ago

Hey there,

I'm trying to set some sytem settings in my app, and therefore i was hoping to use this plugin to handle the permissions. Unfortunately, when I'm trying to request the permission it simply fails. I found a solution by manually asking with this code:

if (android.provider.Settings.System.canWrite(application.android.context)) {
  // permission granted
} else {
  const intent = new android.content.Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
  intent.setData(android.net.Uri.parse("package:" + application.android.foregroundActivity.getPackageName()));
  intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
  application.android.foregroundActivity.startActivity(intent);
}

Maybe something like this could be added to this plugin?

NathanaelA commented 5 years ago

Code similar to this has been added to version 1.3.5 of the plugin. ;-)