Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking Previously Granted Permissions in React Native using PermissionsAndroid API

Is there a way to check if a list of permissions have already been granted in React Native using the PermissionsAndroid API, similar to how PermissionsAndroid.requestMultiple() can be used to request multiple permissions? I'm looking for a method like PermissionsAndroid.checkMultiple() to allow me to check if a list of permissions were already granted.

I would appreciate some suggestions on this.

like image 871
Abdoul Avatar asked Mar 03 '26 17:03

Abdoul


1 Answers

The simple wrapper would be something like this (not the same thing, but solves the problem):

const checkPermissions = (permissions: Permission[]): Promise<boolean[]> => {
  return Promise.all(permissions.map((p) => PermissionsAndroid.check(p)))
}

let granted = await checkPermissions([
  PermissionsAndroid.PERMISSIONS.CAMERA,
  PermissionsAndroid.PERMISSIONS.RECORD_AUDIO
])
console.log(granted) // [false,false]
like image 89
user18309290 Avatar answered Mar 05 '26 07:03

user18309290