{"id":19220053,"url":"https://github.com/nativescript-community/perms","last_synced_at":"2025-05-07T13:05:51.885Z","repository":{"id":41203147,"uuid":"179716050","full_name":"nativescript-community/perms","owner":"nativescript-community","description":"An unified permissions API for NativeScript on iOS and Android.","archived":false,"fork":false,"pushed_at":"2025-03-27T17:29:03.000Z","size":3880,"stargazers_count":13,"open_issues_count":14,"forks_count":10,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-07T13:05:44.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nativescript-community.github.io/perms/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nativescript-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["farfromrefug"]}},"created_at":"2019-04-05T16:18:44.000Z","updated_at":"2025-03-30T03:16:27.000Z","dependencies_parsed_at":"2023-11-22T16:27:39.993Z","dependency_job_id":"dde35867-973c-4d5d-9261-bcee83d144e7","html_url":"https://github.com/nativescript-community/perms","commit_stats":{"total_commits":204,"total_committers":8,"mean_commits":25.5,"dds":0.0490196078431373,"last_synced_commit":"f22ea7f611dbd29af79b22753fc58ea5d88c22c0"},"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fperms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fperms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fperms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fperms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nativescript-community","download_url":"https://codeload.github.com/nativescript-community/perms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883206,"owners_count":21819160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T14:33:48.001Z","updated_at":"2025-05-07T13:05:51.861Z","avatar_url":"https://github.com/nativescript-community.png","language":"TypeScript","funding_links":["https://github.com/sponsors/farfromrefug"],"categories":[],"sub_categories":[],"readme":"\u003c!-- ⚠️ This README has been generated from the file(s) \"blueprint.md\" ⚠️--\u003e\u003c!-- ⚠️ This README has been generated from the file(s) \"blueprint.md\" ⚠️--\u003e\n\u003c!--  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      DO NOT EDIT THIS READEME DIRECTLY! Edit \"bluesprint.md\" instead.\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --\u003e\n\u003ch1 align=\"center\"\u003e@nativescript-community/perms\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\t\t\u003ca href=\"https://npmcharts.com/compare/@nativescript-community/perms?minimal=true\"\u003e\u003cimg alt=\"Downloads per month\" src=\"https://img.shields.io/npm/dm/@nativescript-community/perms.svg\" height=\"20\"/\u003e\u003c/a\u003e\r\n\u003ca href=\"https://www.npmjs.com/package/@nativescript-community/perms\"\u003e\u003cimg alt=\"NPM Version\" src=\"https://img.shields.io/npm/v/@nativescript-community/perms.svg\" height=\"20\"/\u003e\u003c/a\u003e\n\t\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eAn unified permissions API for NativeScript on iOS and Android.\u003c/b\u003e\u003c/br\u003e\n  \u003csub\u003e\u003csub\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n\n| \u003cimg src=\"https://raw.githubusercontent.com/nativescript-community/gps/master/images/demo-ios.gif\" height=\"500\" /\u003e | \u003cimg src=\"https://raw.githubusercontent.com/nativescript-community/gps/master/images/demo-android.gif\" height=\"500\" /\u003e |\n| --- | ----------- |\n| iOS Demo | Android Demo |\n\n\r\n[](#table-of-contents)\r\n\r\n\r\n[](#table-of-contents)\r\n\r\n## Table of Contents\n\n* [Installation](#installation)\r\n* [API](#api)\r\n\t* [Permissions statuses](#permissions-statuses)\r\n\t* [Supported permissions types](#supported-permissions-types)\r\n\t* [Methods](#methods)\r\n\t* [iOS Notes](#ios-notes)\r\n\t\t* [App Store submission disclaimer](#app-store-submission-disclaimer)\r\n\t* [Android Notes](#android-notes)\r\n* [Troubleshooting](#troubleshooting)\r\n\t\t* [Q: iOS - App crashes as soon as I request permission](#q-ios---app-crashes-as-soon-as-i-request-permission)\r\n\t\t* [Q: iOS - App crashes when I change permission from settings](#q-ios---app-crashes-when-i-change-permission-from-settings)\n\n\r\n[](#installation)\r\n\r\n\r\n[](#installation)\r\n\r\n## Installation\nRun the following command from the root of your project:\n\n`ns plugin add @nativescript-community/perms`\n\n\r\n[](#api)\r\n\r\n\r\n[](#api)\r\n\r\n## API\n\n### Permissions statuses\n\nPromises resolve into ```[status:Status, always:boolean]``` where status is one of these statuses:\n\n| Return value   | Notes                                                                                                                                                                                                                                                                  |\n| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `authorized`   | User has authorized this permission                                                                                                                                                                                                                                    |\n| `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'                                                                          |\n| `limited`   | **iOS** - this means the permission is granted but with limitations                                                                                                                                                                                                    |\n| `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 |\n| `undetermined` | User has not yet been prompted with a permission dialog                                                                                                                                                                                                                |\n\n### Supported permissions types\n\nThe current supported permissions are:\n\n|                    | Type                | iOS | Android |\n| ------------------ | ------------------- | --- | ------- |\n| Location           | `location`          | ✔  | ✔       |\n| Camera             | `camera`            | ✔  | ✔       |\n| Microphone         | `microphone`        | ✔  | ✔       |\n| Photos             | `photo`             | ✔  | ✔       |\n| Videos             | `video`             | ❌ | ✔ (api \u003e= 33)       |\n| Audio              | `audio`             | ❌ | ✔ (api \u003e= 33)       |\n| Contacts           | `contacts`          | ✔  | ✔       |\n| Events             | `event`             | ✔  | ✔       |\n| Bluetooth          | `bluetooth`         | ✔  | ✔(api \u003e= 31)      |\n| Reminders          | `reminder`          | ✔  | ❌      |\n| Push Notifications | `notification`      | ✔  | ✔ (api \u003e= 33)       |\n| Background Refresh | `backgroundRefresh` | ✔  | ❌      |\n| Speech Recognition | `speechRecognition` | ✔  | ❌      |\n| Media Library      | `mediaLibrary`      | ✔  | ❌      |\n| Motion Activity    | `motion`            | ✔  | ❌      |\n| Storage            | `storage`           | ❌️ | ✔       |\n| Phone Call         | `callPhone`         | ❌️ | ✔       |\n| Read SMS           | `readSms`           | ❌️ | ✔       |\n| Receive SMS        | `receiveSms`        | ❌️ | ✔       |\n| Media Location        | `mediaLocation`        | ❌️ | ✔(api \u003e= 29)       |\n| Bluetooth Scan        | `bluetoothScan`        | ❌️ | ✔(api \u003e= 31)       |\n| Bluetooth Connect        | `bluetoothConnect`        | ❌️ | ✔(api \u003e= 31)       |\n\n### Methods\n\n| Method Name         | Arguments | Notes                                                                                                                                                                                                                                                                            |\n| ------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `check()`           | `type`    | - Returns a promise with the permission status. See iOS Notes for special cases                                                                                                                                                                                                  |\n| `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 |\n| `checkMultiple()`   | `{[key:string]:Record\u003cstring, any\u003e}` | - Accepts an array of permission types and returns a promise with an object mapping permission types to statuses                                                                                                                                                                 |\n| `getTypes()`        | _none_    | - Returns an array of valid permission types                                                                                                                                                                                                                                     |\n| `openSettings()`    | _none_    | - Switches the user to the settings page of your app                                                                                                                                                                                                |\n| `canOpenSettings()` | _none_    | - Returns a boolean indicating if the device supports switching to the settings page                                                                                                                                                                                |\n\n### iOS Notes\n\n* Permission type `bluetooth` represents the status of the\n  `CBPeripheralManager`. Don't use this if only need `CBCentralManager`\n* Permission type `location` accepts a second parameter for `request()` and\n  `check()`; the second parameter is a string, either `always` or `whenInUse`\n  (default).\n* Permission type `notification` accepts a second parameter for `request()`. The\n  second parameter is an array with the desired alert types. Any combination of\n  `alert`, `badge` and `sound` (default requests all three).\n* iOS 12+: The second parameter also takes this type inside of the array `providesAppNotificationSettings`.\n* If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project\n\n```js\nimport { check as checkPermission, request as requestPermission } from '@nativescript-community/perms';\n\n// example\ncheckPermission('location', { type: 'always' }).then(response =\u003e {\n  this.setState({ locationPermission: response[0] })\n})\n\nrequestPermission('location', { type: 'always' }).then(response =\u003e {\n  this.setState({ locationPermission: response[0] })\n})\n\nrequestPermission('notification', { type: ['alert', 'badge'] }).then(\n  response =\u003e {\n    this.setState({ notificationPermission: response[0] })\n  },\n)\n```\n\n* You cannot request microphone permissions on the simulator.\n* With Xcode 8, you now need to add usage descriptions for each permission you\n  will request. Open Xcode ➜ `Info.plist` ➜ Add a key (starting with \"Privacy -\n  ...\") with your kit specific permission.\n\nExample: If you need Contacts permission you have to add the key `Privacy -\nContacts Usage Description`.\n\n\u003cimg width=\"338\" alt=\"3cde3b44-7ffd-11e6-918b-63888e33f983\" src=\"https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png\"\u003e\n\n#### App Store submission disclaimer\n\nIf you need to submit you application to the AppStore, you need to add to your\n`Info.plist` all `*UsageDescription` keys with a string value explaining to the\nuser how the app uses this data. **Even if you don't use them**.\n\nSo before submitting your app to the App Store, make sure that in your\n`Info.plist` you have the following keys:\n\n```xml\n\u003ckey\u003eNSBluetoothPeripheralUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSCalendarsUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSLocationWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSPhotoLibraryAddUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSSpeechRecognitionUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSAppleMusicUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n\u003ckey\u003eNSMotionUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome description\u003c/string\u003e\n```\nThis is required because during the phase of processing in the App Store\nsubmission, the system detects that you app contains code to request the\npermission `X` but don't have the `UsageDescription` key and then it rejects the\nbuild.\n\n\u003e Please note that it will only be shown to the users the usage descriptions of\n\u003e the permissions you really require in your app.\n\nYou can find more information about this issue in #46.\n\n### Android Notes\n\n* `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\n* All required permissions also need to be included in the `AndroidManifest.xml`\n  file before they can be requested. Otherwise `request()` will immediately\n  return `denied`.\n* You can request write access to any of these types by also including the\n  appropriate write permission in the `AndroidManifest.xml` file. Read more\n  [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).\n\n* Permissions are automatically accepted for **targetSdkVersion \u003c 23** but you\n  can still use `check()` to check if the user has disabled them from Settings.\n\nYou might need to elevate the **targetSdkVersion** version in your\n`build.gradle`:\n\n```groovy\nandroid {\n  compileSdkVersion 23 // ← set at least 23\n  buildToolsVersion \"23.0.1\"  // ← set at least 23.0.0\n\n  defaultConfig {\n    minSdkVersion 16\n    targetSdkVersion 23 // ← set at least 23\n    // ...\n```\n\n\r\n[](#troubleshooting)\r\n\r\n\r\n[](#troubleshooting)\r\n\r\n## Troubleshooting\n\n#### Q: iOS - App crashes as soon as I request permission\n\n\u003e A: Starting with Xcode 8, you need to add permission descriptions. See iOS\n\u003e notes for more details. Thanks to [@jesperlndk](https://github.com/jesperlndk)\n\u003e for discovering this.\n\n#### Q: iOS - App crashes when I change permission from settings\n\n\u003e A: This is normal. iOS restarts your app when your privacy settings change.\n\u003e Just google \"iOS crash permission change\"\n\n\r\n[](#demos-and-development)\r\n\r\n## Demos and Development\n\n\n### Repo Setup\n\nThe repo uses submodules. If you did not clone with ` --recursive` then you need to call\n```\ngit submodule update --init\n```\n\nThe package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.\n\nTo develop and test:\nif you use `yarn` then run `yarn`\nif you use `pnpm` then run `pnpm i`\n\n**Interactive Menu:**\n\nTo start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.\n\n### Build\n\n```bash\nnpm run build.all\n```\nWARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`\n\n### Demos\n\n```bash\nnpm run demo.[ng|react|svelte|vue].[ios|android]\n\nnpm run demo.svelte.ios # Example\n```\n\nDemo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`\nInstead you work in `demo-snippets/[ng|react|svelte|vue]`\nYou can start from the `install.ts` of each flavor to see how to register new demos \n\n\r\n[](#contributing)\r\n\r\n## Contributing\n\n### Update repo \n\nYou can update the repo files quite easily\n\nFirst update the submodules\n\n```bash\nnpm run update\n```\n\nThen commit the changes\nThen update common files\n\n```bash\nnpm run sync\n```\nThen you can run `yarn|pnpm`, commit changed files if any\n\n### Update readme \n```bash\nnpm run readme\n```\n\n### Update doc \n```bash\nnpm run doc\n```\n\n### Publish\n\nThe publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)\nSimply run \n```shell\nnpm run publish\n```\n\n### modifying submodules\n\nThe repo uses https:// for submodules which means you won't be able to push directly into the submodules.\nOne easy solution is t modify `~/.gitconfig` and add\n```\n[url \"ssh://git@github.com/\"]\n\tpushInsteadOf = https://github.com/\n```\n\r\n[](#questions)\r\n\r\n## Questions\n\nIf you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-community%2Fperms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnativescript-community%2Fperms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-community%2Fperms/lists"}