mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
20 lines
557 B
TypeScript
20 lines
557 B
TypeScript
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;
|
|
|
|
let result = await PermissionsAndroid.check(permissions);
|
|
if (result !== PermissionsAndroid.RESULTS.GRANTED) {
|
|
result = await PermissionsAndroid.request(permissions, rationale);
|
|
}
|
|
return result === PermissionsAndroid.RESULTS.GRANTED;
|
|
};
|