2020-06-08 10:01:11 +02:00
|
|
|
const { Platform, PermissionsAndroid } = require('react-native');
|
|
|
|
|
|
|
|
type rationale = {
|
|
|
|
title: string,
|
|
|
|
message: string,
|
|
|
|
buttonPositive: string,
|
|
|
|
buttonNegative?: string
|
|
|
|
buttonNeutral?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export default async (permissions: string, rationale?: rationale) => {
|
|
|
|
if (Platform.OS !== 'android') return true;
|
2020-06-04 19:40:44 +02:00
|
|
|
|
|
|
|
let result = await PermissionsAndroid.check(permissions);
|
|
|
|
if (result !== PermissionsAndroid.RESULTS.GRANTED) {
|
2020-06-08 10:01:11 +02:00
|
|
|
result = await PermissionsAndroid.request(permissions, rationale);
|
2020-06-04 19:40:44 +02:00
|
|
|
}
|
|
|
|
return result === PermissionsAndroid.RESULTS.GRANTED;
|
|
|
|
};
|