;
```
```js
import {request, PERMISSIONS} from 'react-native-permissions';
request(PERMISSIONS.IOS.LOCATION_ALWAYS).then((result) => {
// โฆ
});
```
#### checkNotifications
Check notifications permission status and get notifications settings values.
```ts
type NotificationSettings = {
// properties only available on iOS
// unavailable settings will not be included in the response object
alert?: boolean;
badge?: boolean;
sound?: boolean;
carPlay?: boolean;
criticalAlert?: boolean;
provisional?: boolean;
providesAppSettings?: boolean;
lockScreen?: boolean;
notificationCenter?: boolean;
};
function checkNotifications(): Promise<{
status: PermissionStatus;
settings: NotificationSettings;
}>;
```
```js
import {checkNotifications} from 'react-native-permissions';
checkNotifications().then(({status, settings}) => {
// โฆ
});
```
#### requestNotifications
Request notifications permission status and get notifications settings values.
- You have to [target at least SDK 33](https://github.com/zoontek/react-native-permissions/releases/tag/3.5.0) to perform request on Android 13+.
- You cannot request notifications permissions on Windows. Disabling / enabling them can only be done through the App Settings.
```ts
// only used on iOS
type NotificationOption =
| 'alert'
| 'badge'
| 'sound'
| 'criticalAlert'
| 'carPlay'
| 'provisional'
| 'providesAppSettings';
type NotificationSettings = {
// properties only available on iOS
// unavailable settings will not be included in the response object
alert?: boolean;
badge?: boolean;
sound?: boolean;
carPlay?: boolean;
criticalAlert?: boolean;
provisional?: boolean;
providesAppSettings?: boolean;
lockScreen?: boolean;
notificationCenter?: boolean;
};
function requestNotifications(options: NotificationOption[]): Promise<{
status: PermissionStatus;
settings: NotificationSettings;
}>;
```
```js
import {requestNotifications} from 'react-native-permissions';
requestNotifications(['alert', 'sound']).then(({status, settings}) => {
// โฆ
});
```
#### checkMultiple
Check multiples permissions in parallel.
_โ ๏ธย ย Android will never return `blocked` on `checkMultiple`, you have to call `requestMultiple` to get the info._
```ts
function checkMultiple(
permissions: P,
): Promise>;
```
```js
import {checkMultiple, PERMISSIONS} from 'react-native-permissions';
checkMultiple([PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.FACE_ID]).then((statuses) => {
console.log('Camera', statuses[PERMISSIONS.IOS.CAMERA]);
console.log('FaceID', statuses[PERMISSIONS.IOS.FACE_ID]);
});
```
#### requestMultiple
Request multiple permissions in sequence.
```ts
function requestMultiple(
permissions: P,
): Promise>;
```
```js
import {requestMultiple, PERMISSIONS} from 'react-native-permissions';
requestMultiple([PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.FACE_ID]).then((statuses) => {
console.log('Camera', statuses[PERMISSIONS.IOS.CAMERA]);
console.log('FaceID', statuses[PERMISSIONS.IOS.FACE_ID]);
});
```
#### openSettings
Open application settings.
```ts
function openSettings(): Promise;
```
```js
import {openSettings} from 'react-native-permissions';
openSettings().catch(() => console.warn('cannot open settings'));
```
#### openPhotoPicker (iOS 14+)
Open a picker to update the photo selection when `PhotoLibrary` permission is `limited`. This will reject if unsupported or if full permission is already `granted`.
```ts
function openPhotoPicker(): Promise;
```
```js
import {openPhotoPicker} from 'react-native-permissions';
openPhotoPicker().catch(() => {
console.warn('Cannot open photo library picker');
});
```
#### checkLocationAccuracy (iOS 14+)
When `LocationAlways` or `LocationWhenInUse` is `granted`, allow checking if the user share his precise location.
```ts
type LocationAccuracy = 'full' | 'reduced';
function checkLocationAccuracy(): Promise;
```
```js
import {checkLocationAccuracy} from 'react-native-permissions';
checkLocationAccuracy()
.then((accuracy) => console.log(`Location accuracy is: ${accuracy}`))
.catch(() => console.warn('Cannot check location accuracy'));
```
#### requestLocationAccuracy (iOS 14+)
When `LocationAlways` or `LocationWhenInUse` is `granted`, allow requesting the user for his precise location. Will resolve immediately if `full` accuracy is already authorized.
```ts
type LocationAccuracyOptions = {
purposeKey: string;
};
type LocationAccuracy = 'full' | 'reduced';
function requestLocationAccuracy(options: LocationAccuracyOptions): Promise;
```
```js
import {requestLocationAccuracy} from 'react-native-permissions';
requestLocationAccuracy({purposeKey: 'YOUR-PURPOSE-KEY'})
.then((accuracy) => console.log(`Location accuracy is: ${accuracy}`))
.catch(() => console.warn('Cannot request location accuracy'));
```
### About iOS `LOCATION_ALWAYS` permission
If you are requesting `PERMISSIONS.IOS.LOCATION_ALWAYS`, there won't be a `Always Allow` button in the system dialog. Only `Allow Once`, `Allow While Using App` and `Don't Allow`. This is expected behaviour, check the [Apple Developer Docs](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization#3578736).
When requesting `PERMISSIONS.IOS.LOCATION_ALWAYS`, if the user choose `Allow While Using App`, a provisional "always" status will be granted. The user will see `While Using` in the settings and later will be informed that your app is using the location in background. That looks like this:
Subsequently, if you are requesting `LOCATION_ALWAYS` permission, there is no need to request `LOCATION_WHEN_IN_USE`. If the user accepts, `LOCATION_WHEN_IN_USE` will be granted too. If the user denies, `LOCATION_WHEN_IN_USE` will be denied too.
### Testing with Jest
If you don't already have a Jest setup file configured, please add the following to your Jest configuration file and create the new `jest.setup.js` file in project root:
```js
setupFiles: ['/jest.setup.js'];
```
You can then add the following line to that setup file to mock the `NativeModule.RNPermissions`:
```js
jest.mock('react-native-permissions', () => require('react-native-permissions/mock'));
```
## Sponsors
This module is provided **as is**, I work on it in my free time.
If you or your company uses it in a production app, consider sponsoring this project ๐ฐ. You also can contact me for **premium** enterprise support: help with issues, prioritize bugfixes, feature requests, etc.
