Get started
Setup
Add the following library dependency to thedependencies section of your package.json file.
Usage
Request run-time privileges
Use the following method to request authorization to access resources such as the camera or microphone. For the full set of permissions available, see PERMISSIONS in PermissionsKepler.getPrivilegeState() for calling package
There are two versions of the getPrivilegeState() method. The version that apps are expected to use is
defined as follows:
await or then() construct.
On success, the payload of the Promise is the current state of the privilege which is one
of the following:
SecurityManagerTypes.PrivilegeState.ALLOW- This indicates that the user has already consented to giving this app the requested privilege. There is no need to request the privilege from the user.SecurityManagerTypes.PrivilegeState.DENY- This indicates that the user has either already been asked for privilege and denied it, or that consent has never been requested. Use therequestPrivilege()method to prompt the user for consent.
requestPrivilege()
Apps use the requestPrivilege() method when they need access to a privilege. The OS responds by launching a Privilege Request Handler,
which is a system component responsible for asking the user for consent and storing the result.
SecurityManagerTypes.PrivilegeState.ALLOW- The user has consented to giving the privilege to the app. The app should continue to access the privileged resources it needs.SecurityManagerTypes.PrivilegeState.DENY- The user rejected the privilege request. The app should degrade functionality gracefully. The app shouldn’t continuously prompt the user to allow access. This method should only be called again after the user has performed another action which indicates that they want the app to access a protected resource.
Example usage
The following example demonstrates how to implement microphone access permissions in your app using the Security Manager. This code shows a complete flow for checking and requesting microphone privileges when a user attempts to access recording functionality, including proper error handling and navigation to appropriate screens based on the user’s permission choice. If permission is granted, the user is directed to the recording screen; if denied, they are shown an access denied screen.Privilege request handlers and the privacy dashboard
The privilege request handler is the system component responsible for getting consent to access a privilege from the user and storing the result. The privacy dashboard is a centralized place in the settings app where users can view and change their privacy settings.getPrivilegeState() for privilege request handlers
The version of the getPrivilegeState() method that privileged components use is defined as follows.
await or then() construct.
On success, the payload of the Promise is the current state of the privilege which is one
of the following:
SecurityManagerTypes.PrivilegeState.ALLOW- This indicates that the user has already consented to giving this app the requested privilege.SecurityManagerTypes.PrivilegeState.DENY- This indicates that the user has either already been asked for privilege and denied it, or that consent has never been requested.
Sample Usage
Access Control
This method requires thecom.amazon.privilege.package.queryrun-time privilege due to the fact that it allows the caller to determine what apps a user has installed, which is a privacy concern. This privilege requires the calling app to have a platform signature.
To prevent privilege fatigue and annoyance, Kepler only shows this modal dialog the first time an app requests a privilege. The user makes a choice using the dialog, and that setting is recorded. The user is free to change that choice at any time through the Settings app.
Privilege errors
If your app uses a service that you didn’t declare on your manifest, you will receive an error when starting your app. The following example log message means the app has not properly declared the WiFi service-dependency in the app manifest.Related topics
Request Run-time PrivilegesModules
- index
- native-security-manager
- SecurityManager
- types
- types
- types/SecurityManagerTypes
- types/SecurityManagerTypes

