1

I have created methods for grant the permission of location and storage read & write using the react-native-permission library. when user is deny the permission then the permission dialog is disabled. But i am trying to do that, the request methods is call in loop until the user allow the permission of location. so, how can i do it. please suggest any solution

Code:

  reuestMultiplePermissions = () => {
    return new Promise((resolve, reject) => {
      requestMultiple([
        PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
        PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
        PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,
        PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE,
      ])
        .then((statuses) => {
          if (
         
            statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION] ===
              RESULTS.GRANTED &&
            statuses[PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION] ===
              RESULTS.GRANTED
          ) {
            resolve(true);
          } else {
            reject({});
          }
        })
        .catch((error) => {
          reject(error);
        });
    });
  };
Sinan Yaman
  • 5,714
  • 2
  • 15
  • 35
vjtechno
  • 452
  • 1
  • 6
  • 16

1 Answers1

1

We can manage this using global variables update the status of the permission in a global variable as per the user input.

and check for the user input if permission granted the do something or ask permission again from user and if user has denied the permission permanently then open ask the user to open settings and allow permission to continue using app.

Jignesh Mayani
  • 6,937
  • 1
  • 20
  • 36