
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
@nativescript-community/perms
Advanced tools
An unified permissions API for NativeScript on iOS and Android.
![]() | ![]() |
|---|---|
| iOS Demo | Android Demo |
Run the following command from the root of your project:
ns plugin add @nativescript-community/perms
Promises resolve into [status:Status, always:boolean] where status is one of these statuses:
| Return value | Notes |
|---|---|
authorized | User has authorized this permission |
denied | User has denied this permission at least once. On iOS this means that the user will not be prompted again. Android users can be prompted multiple times until they select 'Never ask me again' |
limited | iOS - this means the permission is granted but with limitations |
restricted | iOS - this means user is not able to grant this permission, either because it's not supported by the device or because it has been blocked by parental controls. Android - this means that the user has selected 'Never ask me again' while denying permission |
undetermined | User has not yet been prompted with a permission dialog |
The current supported permissions are:
| Type | iOS | Android | |
|---|---|---|---|
| Location | location | β | β |
| Camera | camera | β | β |
| Microphone | microphone | β | β |
| Photos | photo | β | β |
| Videos | video | β | β (api >= 33) |
| Audio | audio | β | β (api >= 33) |
| Contacts | contacts | β | β |
| Events | event | β | β |
| Bluetooth | bluetooth | β | β(api >= 31) |
| Reminders | reminder | β | β |
| Push Notifications | notification | β | β (api >= 33) |
| Background Refresh | backgroundRefresh | β | β |
| Speech Recognition | speechRecognition | β | β |
| Media Library | mediaLibrary | β | β |
| Motion Activity | motion | β | β |
| Storage | storage | βοΈ | β |
| Phone Call | callPhone | βοΈ | β |
| Read SMS | readSms | βοΈ | β |
| Receive SMS | receiveSms | βοΈ | β |
| Media Location | mediaLocation | βοΈ | β(api >= 29) |
| Bluetooth Scan | bluetoothScan | βοΈ | β(api >= 31) |
| Bluetooth Connect | bluetoothConnect | βοΈ | β(api >= 31) |
| Method Name | Arguments | Notes |
|---|---|---|
check() | type | - Returns a promise with the permission status. See iOS Notes for special cases |
request() | type | - Accepts any permission type except backgroundRefresh. If the current status is undetermined, shows the permission dialog and returns a promise with the resulting status. Otherwise, immediately return a promise with the current status. See iOS Notes for special cases |
checkMultiple() | {[key:string]:Record<string, any>} | - Accepts an array of permission types and returns a promise with an object mapping permission types to statuses |
getTypes() | none | - Returns an array of valid permission types |
openSettings() | none | - Switches the user to the settings page of your app |
canOpenSettings() | none | - Returns a boolean indicating if the device supports switching to the settings page |
bluetooth represents the status of the
CBPeripheralManager. Don't use this if only need CBCentralManagerlocation accepts a second parameter for request() and
check(); the second parameter is a string, either always or whenInUse
(default).notification accepts a second parameter for request(). The
second parameter is an array with the desired alert types. Any combination of
alert, badge and sound (default requests all three).providesAppNotificationSettings.import { check as checkPermission, request as requestPermission } from '@nativescript-community/perms';
// example
checkPermission('location', { type: 'always' }).then(response => {
this.setState({ locationPermission: response[0] })
})
requestPermission('location', { type: 'always' }).then(response => {
this.setState({ locationPermission: response[0] })
})
requestPermission('notification', { type: ['alert', 'badge'] }).then(
response => {
this.setState({ notificationPermission: response[0] })
},
)
Info.plist β Add a key (starting with "Privacy -
...") with your kit specific permission.Example: If you need Contacts permission you have to add the key Privacy - Contacts Usage Description.
If you need to submit you application to the AppStore, you need to add to your
Info.plist all *UsageDescription keys with a string value explaining to the
user how the app uses this data. Even if you don't use them.
So before submitting your app to the App Store, make sure that in your
Info.plist you have the following keys:
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Some description</string>
<key>NSCalendarsUsageDescription</key>
<string>Some description</string>
<key>NSCameraUsageDescription</key>
<string>Some description</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Some description</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Some description</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Some description</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>Some description</string>
<key>NSAppleMusicUsageDescription</key>
<string>Some description</string>
<key>NSMotionUsageDescription</key>
<string>Some description</string>
This is required because during the phase of processing in the App Store
submission, the system detects that you app contains code to request the
permission X but don't have the UsageDescription key and then it rejects the
build.
Please note that it will only be shown to the users the usage descriptions of the permissions you really require in your app.
You can find more information about this issue in #46.
check and request also allows you to directly pass android permission(s) as a value or an array. This would allow to request any new permission without a required update of this plugin
All required permissions also need to be included in the AndroidManifest.xml
file before they can be requested. Otherwise request() will immediately
return denied.
You can request write access to any of these types by also including the
appropriate write permission in the AndroidManifest.xml file. Read more
here.
Permissions are automatically accepted for targetSdkVersion < 23 but you
can still use check() to check if the user has disabled them from Settings.
You might need to elevate the targetSdkVersion version in your
build.gradle:
android {
compileSdkVersion 23 // β set at least 23
buildToolsVersion "23.0.1" // β set at least 23.0.0
defaultConfig {
minSdkVersion 16
targetSdkVersion 23 // β set at least 23
// ...
A: Starting with Xcode 8, you need to add permission descriptions. See iOS notes for more details. Thanks to @jesperlndk for discovering this.
A: This is normal. iOS restarts your app when your privacy settings change. Just google "iOS crash permission change"
FAQs
An unified permissions API for NativeScript on iOS and Android.
The npm package @nativescript-community/perms receives a total of 2,462 weekly downloads. As such, @nativescript-community/perms popularity was classified as popular.
We found that @nativescript-community/perms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 20 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.