Permissions Handling API
Manage device permissions using the WebToNative JavaScript API. Request, check, and handle permissions for Android and iOS apps.
Functions to manage device permissions and hardware/service states from your website. You can check the current status of one or more permissions without prompting, request a single permission (showing the native system dialog when needed), and open the system settings screen so the user can re-enable a permission manually.
You'll need to import the JavaScript file into your website before starting from this link.
Platform support: Android and iOS. All three functions work identically on both platforms unless a platform note states otherwise.
Status Values
Every permission-related callback returns one of the following status strings.
ALLOWED
Permission is granted. The feature can be used.
NOT_ALLOWED
Permission is not granted but a dialog can still be shown it has never been asked, was denied once (and can be asked again), or the device service is off.
PERMANENTLY_BLOCKED
The user selected "Don't ask again" (Android) or denied the permission from Settings (iOS). No dialog can be shown the user must open Settings manually.
RESTRICTED
A system-level policy (parental controls, MDM) prevents the permission. The user cannot change it. iOS only.
UNKNOWN_STATUS
The status cannot be determined on this platform or device.
Supported Permissions
These values are accepted by both request and check.
camera
Camera access
✅
✅
location
Location access (while using the app)
✅
✅
location_always
Location access at all times, including background
✅
✅
notification
Push notification delivery
✅
✅
record_audio
Microphone access
✅
✅
contact
Read device contacts
✅
✅
bluetooth
Bluetooth access
✅
✅
Contact and Bluetooth are only active when the corresponding native module is enabled in your app configuration. If the module is disabled, the callback returns NOT_ALLOWED immediately without showing a dialog.
Supported Device States
These values represent hardware or service toggles, not grantable permissions. They are accepted only by check (and by open) they cannot be passed to request.
enableBluetooth
Whether the Bluetooth radio is currently on
✅
✅
enableNfc
Whether NFC is currently enabled
✅
✅
enableLocation
Whether Location Services are enabled system-wide
✅
✅
iOS cannot check the Bluetooth power state synchronously enableBluetooth returns UNKNOWN_STATUS on iOS.
Check
Checks the current status of one or more permissions or device states without showing any dialog. Results for all requested items are returned together in a single callback.
Parameters:
permissions
String[]
Yes
One or more permission or device-state values to check.
callback
Function
No
Callback function invoked with the status of all requested items.
Callback Response:
type
String
Always "checkPermission".
permissionStatus
Object
A key-value map where each key is a permission value you passed in and each value is one of the status strings above.
Example response:
Notes:
On Android, a permission that has never been requested returns
NOT_ALLOWED(notPERMANENTLY_BLOCKED).PERMANENTLY_BLOCKEDis only returned once the user has been shown a dialog at least once and selected "Don't ask again".
Request
Requests a single permission from the user. Shows the native system dialog if the permission has not been granted yet. If it is already granted the callback fires immediately with ALLOWED; if it is permanently blocked the callback fires immediately with PERMANENTLY_BLOCKED no dialog is shown.
Parameters:
permission
String
Yes
A single permission value to request. Device-state values (enableBluetooth, etc.) are not accepted.
callback
Function
No
Callback function invoked with the outcome of the request.
Callback Response:
type
String
Always "requestPermission".
status
String
One of the status strings above, reflecting the request outcome.
Example response:
Notes:
Only one permission can be requested per call.
On iOS,
notificationpermission can only be requested once. After it is denied, subsequent calls returnPERMANENTLY_BLOCKEDimmediately.
Open
Opens the system settings screen for a specific permission or device state. Use this when check or request returns PERMANENTLY_BLOCKED and you want to guide the user to re-enable the permission manually. Optionally show a native confirmation dialog before navigating to Settings.
Parameters:
permission
String
Yes
The permission or device-state value whose settings screen to open. Accepts all permission and device-state values.
alertDialogStyle
Object
No
When provided, a native confirmation dialog is shown before navigating to Settings. If omitted, Settings opens immediately.
alertDialogStyle.title
String
No
Dialog title. Defaults to a permission-name-based title if omitted.
alertDialogStyle.message
String
No
Dialog body text. A generic message is used if omitted.
alertDialogStyle.positiveText
String
No
Text for the confirm button. Defaults to "Settings".
alertDialogStyle.negativeText
String
No
Text for the cancel button. Defaults to "Cancel".
Notes:
Device-state values (
enableBluetooth,enableNfc,enableLocation) work withcheckandopenonly never withrequest.
Last updated