Permissions Overview
Some device hardware and functionality requires specific permissions from the user to be able to be accessed by your app. Typically permission requests can be configured to be prompted when the app is first launched by the user or they can be prompted in-context when required at runtime via the JavaScript Bridge. Apple and Google encourage developers to request permission thoughtfully. If a user has declined you can suggest they enable the permission through the app's settings menu and then include a button that launches the app settings screen using the JavaScript Bridge.
Overview
Mobile app permissions play a critical role in ensuring a seamless and secure interaction between users and applications. They serve as a framework that enables apps to access specific features or data on a user’s device, such as the camera, microphone, location, or contact list and allow the user to retain complete control over their privacy and data security.
By granting these permissions, users allow apps to deliver tailored functionalities and enhance their overall experience. Additionally, some of your Native Plugins may require certain device permissions to fulfill their use case.
Permission Prompts
When requesting permissions from your users, they will be asked to provide their consent. Those prompts are native app components with very limited amount of customization.
- Android: Android permission prompts are served from the system and are translated to the device language. No additional customization is supported.
- iOS: iOS allows a customizable usage description for permission prompts, enabling developers to explain how the requested data will be used. Additionally, you can follow the Permission Prompt Localization to localize the usage description
Permissions Status
Developer Demo
Display our demo page in your app to test during development https://median.dev/permissions/
Users can change the permissions granted to your app through their device settings. You can programmatically check the status of permissions granted by the user or device using the following Median JavaScript Bridge call:
↔️Median JavaScript Bridge
// get status of all permissions const response = await median.permissions.status(); // only get status of selected permissions const response = await median.permissions.status(['Contacts', 'Camera']);
The response
object will include the current state for each requested permission similar to the example below:
{
"Contacts": 'undetermined',
"Camera": 'granted'
}
Each permission can have the following states:
undetermined
: The permission was never asked (Only on iOS)granted
: The permission has been granteddenied
: The permission has been denied or has been revoked after being granted and can be asked for again
Status can be fetched for the following permission types:
Notifications
Camera
Contacts
Microphone
LocationWhenInUse
LocationAlways
AppTrackingTransparency
(Only for iOS)PhotoLibrary
(Only for iOS)
App Settings
Developer Demo
Display our demo page in your app to test launching the app settings menu during development https://median.dev/app-settings
In cases where users have denied permissions, you may need to direct them to the app's settings page to enable the required permissions. Use the following Median JavaScript Bridge call:
↔️Median JavaScript Bridge
To open the Settings page for your app, open the URL:
median.open.appSettings();
Updated 3 months ago