Forcing Android permissions

4400
5
05-15-2018 02:14 PM
by Anonymous User
Not applicable

Hi all.

I have an app that is published into the Google Play store. In order for the map to load and work, it requires the 'External Storage' permission. I have ticked this in the AppStudio settings, and it works fine.

Except....   when installing from the Play store, the user is given the OPTION of granting the app that permission. We have had several users deny that permission, then complain that the app doesn't work!

So, I can see two possible options and I'm asking if anyone knows how or whether they can be done, or any other suggestions....

1) Is there a way we can lock the permission so that the user CAN'T install the app unless it has that permission? I'd rather they didn't install than install and not have it work.

2) Is there a way that the app can 'detect' if it has access to the file storage? What could I do to test this on startup and pop up a warning if it doesn't have access?

Or any other suggestions?

cheers,

-Paul

0 Kudos
5 Replies
ShobanaSuresh
Esri Contributor

Hi Paul,

Is the app being built using AppStudio 3.0?

If yes, then the app's targetSdkVersion is set to 23 by default. This enforces the behavior listed under Runtime permission request in below documentation.

Permissions Overview  |  Android Developers 

1. If the device is running Android 6.0 (API level 23) or higher, users will not be notified of any app permissions at install time.

File Read / Write access is categorized as a dangerous permission. So, by default the app will not have read/write access to phone memory.  Your app must ask the user to grant the dangerous permissions at runtime. As described in my last comment in Android SDK version in APK , this is already handled in AppStudio 3.0.

When AppFramework FileFolder / FileInfo components are used in the app, a system dialog requesting permission is displayed to the user. The dialog includes a Deny and Allow button. Are the users denying permission in this dialog that appears when the app is running?

2. If the device is running Android 5.1.1 (API level 22) or lower, the system will automatically ask the user to grant all dangerous permissions for your app at install-time. The installation will not proceed if user denies the permission request. This is the same behavior in apps built using AppStudio 2.1 where the default targetSdkVersion is set to 16.

Thanks

Shobana

0 Kudos
by Anonymous User
Not applicable

Hi Shobana

Yes, what you describe is exactly what we are experiencing. The issue is, as you mention, that some users running Android 6.0 or higher can (and have) deny the permission and then the app doesn't work. Do you have any suggestions on how we can mitigate that experience?

I'm going to test today having a white rectangle over the top of the map, then attempt to copy a file and if the copy works then hide the rectangle and if it fails then leave it there with a descriptive text saying they need to grant the app the file storage permission, or something along those lines. Basically denying them access until they have granted permission.

cheers,

-Paul

0 Kudos
ShobanaSuresh
Esri Contributor

Hi Paul,

Currently, the only way I could think of for improving the experience is what you describe.

App can display a warning message to the user if the file operation fails. Users can then either go to device settings -> Apps -> appname -> permissions -> enable Storage. Or, the app itself can attempt to do the file copy operation again which would bring up the permission dialog if the permission was not previously accepted.

In a future AppStudio release, we are planning to add support in AppFramework to query if a capability has been enabled and accepted by the user. 

Thanks

Shobana

by Anonymous User
Not applicable

Just as a follow up, after a bit of discussion and testing, I've gone with a simple test to create a folder on startup in the user home folder. If that works then I go on to set the source of a Loader object to continue and run the app, else I set an error screen to the Loader.

There was some discussion around what folders were actually being accessed and what permissions were required. We thought maybe the app.settings object was requiring the permissions, and tried to use a custom Settings{} object to see if I could get away with not requiring the file storage permission at all, but I couldn't find a way to NOT require that permission so just went with the above solution.

cheers,

-Paul

0 Kudos
MarikaVertzonis
Esri Regular Contributor

Just for a comparison on how to deal with permissions...

Today I came across a couple of apps, that deal with a similar issue. When creating an app that connects to Bluetooth LE devices, you need to enable Location, even though you may not be using Location in your app.

In the app LightBlue, they display a message that essentially says ' you have to, and its not our fault'. When you click OK you get the operating systems 'allow app to access the devices location message', and until you click allow on that one, you keep getting this message:

The warning message in LightBlue app

In the other app, Bluetooth LE Scanner, you get nothing on start up but when you click 'Scan' you get the operating systems 'allow app to access the devices location message'. If you click 'Deny', you get a system notification that lasts on the screen for 4 seconds. Its not great, but each time you click scan you do get the notification, until you click 'Allow'.

Bluetooth LE Scanner system message

0 Kudos