React-native-permissions: How can we request for multiple permissions?

Created on 7 May 2017  路  7Comments  路  Source: zoontek/react-native-permissions

I am trying to ask user for permission to camera and photos. Even though i looped two request permission calls it shows popup for one an then closes.

Then I have to click on the same button and it asks for the second permission.

How can i get to show multiple permissions in a loop?

Most helpful comment

I tried something like this, and it seemed to work...

    Permissions.request("location")
      .then(locationResponse => {
        console.log("location permission: " + locationResponse);
        return (Permissions.request("camera"));
      }).then(cameraResponse => {
      console.log("camera permission: " + cameraResponse);
      return (Permissions.request("photo"));
    }).then(photoResponse => {
      console.log("photo permission: " + photoResponse);
    });

All 7 comments

+1

@sahil290791 did you ever solve this problem?

@mbenjamin618 No, was unable to find a solution.

Faced the same issue.
I think that the documentation is outdated.
In ReactNativePermissions.js there is not method 'check', use getPermissionStatus

getPermissionStatus(permission, type) {
  if (this.getPermissionTypes().indexOf(permission) >= 0) {
    return RNPermissions.getPermissionStatus(permission, type)
  } else {
   return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on ${Platform.OS}`)
  }
}

@alex-nask - check is the new method name in version 1.0.0. I'll be pushing it to NPM shortly.

@sahil290791 - looping should work, can you share the code that you tried?

I tried something like this, and it seemed to work...

    Permissions.request("location")
      .then(locationResponse => {
        console.log("location permission: " + locationResponse);
        return (Permissions.request("camera"));
      }).then(cameraResponse => {
      console.log("camera permission: " + cameraResponse);
      return (Permissions.request("photo"));
    }).then(photoResponse => {
      console.log("photo permission: " + photoResponse);
    });

closing for inactivity

Was this page helpful?
0 / 5 - 0 ratings