Nativescript Permission Plugin


#1

I used the nativescript-permissions plugin to request permission to store a file in the Download folder. I am having a challenge with the prompt that is displayed to the user as it gives a general message for Photos and others.

This prompt tends to ‘scare’ the users from granting the permission as they are made to believe the App is trying to access things beyond just storing the file.

I wanted to know if there is a way of overriding or customizing the message prompt for the WRITE storage permission.

From this link -


the documentation states:

permissions.requestPermission(permissionName, explanation);

  • permissionName - The permission you are requesting - REQUIRED
  • explanation - This can be either a string that will show as a toast at the top of the screen or this can be a function callback that will be called so that you can show whatever you want. - OPTIONAL.

I was thinking using a callback function would override the default prompt message and show “whatever you want” as stated instead if just a toast that flashes at the top of the screen. I tried including a callback function but it still appeared as a toast.

Please, can you help me out with overriding the default prompt message.


#2

A simple answer is - No, you can’t customize the permission dialog / message in it (not limited by NativeScript but by Android itself). But what you can do is, show a message before making a call to request permissions.

If you closely noticed other apps, most will show some info on the screen that explains why they need the permission and what they are going to do, right below a button that will trigger the permission dialog.


#3

@manojdcoder Thanks for the response. I wonder how mobile browser apps get their permission.

I removed storage permission for my Chrome Mobile App from Settings -> Apps -> Chrome -> Permissions (turned off storage permissions). Then I tried to download a file using Chrome and it displays a different & direct message prompt - “Chrome needs storage access to download files”. This message prompt is preferable as it won’t give users cause to doubt the intent of the requested permission as is the case when Photos and other things are included in the prompt.

How do I achieve something similar to the Chrome permission request’s message prompt to download/save a file?


#4

@manojdcoder Oh, it does exactly what you said. Accepting the direct message I spoke about in my previous reply still proceeds to display the same default android permission request’s message prompt which includes photos & other things.

This seems to be the only way around it. Thanks a lot.