VK1
VK1

Reputation: 1726

How do I request permissions during installation / before app starts for a React Native app?

I would like for the user to grant permissions during installation /before the app begins, rather than being prompted while the app is running. Currently, I'm requesting Coarse Location and Microphone access on the Android version of my app and BLE and Microphone access on the IOS version of the app.

Upvotes: 1

Views: 1288

Answers (1)

Meeran Tariq
Meeran Tariq

Reputation: 1436

That's not possible to do, according to the Android documentations, you can ask for permissions at the installation time only if the android version is less than Marshmallow (i.e. < SDK 23). If the android version is marshmallow or greater then permissions will be asked at the run time, you can't change it.

If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the app requests permissions from the user at run-time. The user can revoke the permissions at any time, so the app needs to check whether it has the permissions every time it accesses permission-protected APIs. For more information about requesting permissions in your app, see the Working with System Permissions training guide.

If the device is running Android 5.1.1 (API level 22) or lower, or the app's targetSdkVersion is 22 or lower, the system asks the user to grant the permissions when the user installs the app. If you add a new permission to an updated version of the app, the system asks the user to grant that permission when the user updates the app. Once the user installs the app, the only way they can revoke the permission is by uninstalling the app.

https://developer.android.com/guide/topics/permissions/requesting.html

And for iOS too, permissions are asked at the runtime, that's like that since iOS 9. I am not sure about what the flow was before iOS 9.

Upvotes: 4

Related Questions