0

I am trying to make a form where people can toggle notifications on and off. I figured the easiest way to do that would be set the permissions to allow or deny but I can't figure out how to remove the permission once it has been granted.

I am triggering the initial permission request by doing the following in android and not too sure what I will do with iOS as it requests the permissions somewhat automatically.

string rec = "android.c2dm.intent.RECEIVE";
string reg = "android.c2dm.intent.REGISTRATION";  
ActivityCompat.RequestPermissions(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity, new string[] { rec, reg },0);

I essentially would like a page that has a few Switch controls to enable/disable permissions.

any help would be greatly appreciated.
Thanks,

1 Answers1

2

There's no built in method for you to toggle a permission (ie, allow, then disallow), but you could do it if your app can run an adb command.

To undo a permission:

adb shell pm revoke <package_name> <permission_name>

To run an adb command within your app, a couple of variations, but all involve:

Process process = Runtime.getRuntime().exec("your command")
TWL
  • 6,228
  • 29
  • 65