https://github.com/3sidedcube/react-native-location-permissions
A React Native library for adding a listener to location permission changes on iOS
https://github.com/3sidedcube/react-native-location-permissions
Last synced: about 1 year ago
JSON representation
A React Native library for adding a listener to location permission changes on iOS
- Host: GitHub
- URL: https://github.com/3sidedcube/react-native-location-permissions
- Owner: 3sidedcube
- License: mit
- Created: 2017-03-20T13:51:18.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-11T11:03:37.000Z (over 6 years ago)
- Last Synced: 2025-01-30T01:22:36.674Z (over 1 year ago)
- Language: Objective-C
- Size: 8.79 KB
- Stars: 0
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-location-permissions
A simple and easy to use library for listening to location permission changes. This only works for iOS.
## Getting started
```
$ npm install react-native-location-permissions --save
$ react-native link
```
## Usage
## API Documentation
#### `locationPermissions#onPermissionsChange(callback)`
- `callback` `Function` The callback to invoke when the user's location permissions change
Registers a callback to be invoked whenever the user's location permissions change. The callback is invoked with an `event` argument which contains a string representation of the current permission under the `status` key.
This method returns a function which you should invoke when you want to unregister the callback, for example, in your app's `componentWillUnmount`.
#### Example
```js
const off = locationPermissions.onPermissionsChange((event) => {
const { status } = event;
if (status === locationPermissions.notDetermined) {
console.log(`Location permissions not yet determined`);
}
else if (status === locationPermissions.authorizedAlways || status === locationPermissions.authorizedWhenInUse) {
console.log(`Location permissions granted`);
} else {
console.log(`Location permissions denied`);
}
});
// Whenever you want to unregister.
off();
```