Yonah Forst 62ef70b38c updated readme | 8 jaren geleden | |
---|---|---|
ReactNativePermissions.xcodeproj | 8 jaren geleden | |
LICENSE | 8 jaren geleden | |
RCTConvert+RNPermissionsStatus.h | 8 jaren geleden | |
RCTConvert+RNPermissionsStatus.m | 8 jaren geleden | |
README.md | 8 jaren geleden | |
ReactNativePermissions.h | 8 jaren geleden | |
ReactNativePermissions.ios.js | 8 jaren geleden | |
ReactNativePermissions.m | 8 jaren geleden | |
package.json | 8 jaren geleden |
Check user permissions (iOS only)
Some iOS features require the user grant permission before you can access them.
This library lets you check the current status of those permissions. (Note: it doesn’t prompt the user, just silently checks the permission status)
The current supported permissions are:
const Permissions = require('react-native-permissions');
//....
componentDidMount() {
Permissions.locationPermissionStatus()
.then(response => {
if (response == Permissions.StatusUndetermined) {
alert("Undetermined");
} else if (response == Permissions.StatusDenied) {
alert("Denied");
} else if (response == Permissions.StatusAuthorized) {
alert("Authorized");
} else if (response == Permissions.StatusRestricted) {
alert("Restricted");
}
});
}
//...
As shown in the example, methods return a promise with the authorization status as an int
. You can compare them to the following statuses: StatusUndetermined
, StatusDenied
, StatusAuthorized
, StatusRestricted
locationPermissionStatus()
- checks for access to the user’s current location. Note: AuthorizedAlways
and AuthorizedWhenInUse
both return StatusAuthorized
cameraPermissionStatus()
- checks for access to the phone’s camera
microphonePermissionStatus()
- checks for access to the phone’s microphone
photoPermissionStatus()
- checks for access to the user’s photo album
contactsPermissionStatus()
- checks for access to the user’s address book
eventPermissionStatus(eventType)
- requires param eventType
; either reminder
or event
. Checks for access to the users calendar events and reminders
bluetoothPermissionStatus()
- checks the authorization status of the CBPeripheralManager
(for sharing data while backgrounded)
notificationPermissionStatus()
- checks if the user has authorized remote push notifications. Note: Apple only tells us if notifications are authorized or not, not the exact status. So this promise only returns StatusUndetermined
or StatusAuthorized
. You can determine if StatusUndetermined
is actually StatusRejected
by keeping track of whether or not you’ve already asked the user for permission.
npm install --save react-native-permissions