rn-smart-permissions
v0.4.2
Published
React native library to handle the runtime permissions in both Android and iOS. Library requests permissions and also handles the related features like turn on bluetooth, turn on location, navigating to settings page etc
Downloads
111
Readme
rn-smart-permissions
Permissions Library for React Native ( Android and iOS). The NPM package is https://www.npmjs.com/package/rn-smart-permissions
Installation
npm install rn-smart-permissions
Advantages
Usage
import { checkAndRequestPermissions, PERMISSION, PERMISSION_RESULT} from 'rn-smart-permissions';
// ...
checkAndRequestPermissions(
PERMISSION.LOCATION,
() => {
//Rationale dialog here
return new Promise((resolve) => {
//show rationale dialog here and resolve the promise with true to continue
});
},
() => {
//blocked permission dialog here
return new Promise((resolve) => {
//show blocked permission dialog here and resolve the promise with true to open settings
});
}
)
.then((result) => {
if (result === PERMISSION_RESULT.AUTHORIZED) {
Alert.alert('', 'Got All access');
}
})
.catch((e) => {
console.log('permission', e);
});
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
Thanks
- https://www.npmjs.com/package/react-native-permissions
- https://www.npmjs.com/package/react-native-android-location-enabler
License
MIT
Made with create-react-native-library