0

The iOS version of the app requires two different permissions: Microphone and BLE. Currently, permissions are being granted on a as needed basis. However, I would like to create a page that allows a user to click on checkbox so that they can grant permission when they first start the app.

Microphone access is asked for via a method which contains the following code:

OVBluetoothManager.startDetectingNoise(NOISE_DETECT_INTERVAL);

Where NOISE_DETECT_INTERVAL is 3000.

BLE is asked for via a method that contains the following code:

OVBluetoothManager.attemptToTriggerLEPairing();

Here are the two methods inside OVBluetoothManager.m file:

RCT_EXPORT_METHOD(attemptToTriggerLEPairing)
{
    [[someManager sharedInstance] getLED];
    [[someManager sharedInstance] getBattery];
}

RCT_EXPORT_METHOD(startDetectingNoise:(NSInteger)timeInterval)
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.noiseDetector startDetectingNoiseWithTimeIntervalInMs:timeInterval];
    });
}

In both cases, the user is prompted by an Alert to grant permissions. Assuming the user grants permission, everything proceeds as usual.

In this post it was suggested that the follow code:

Permissions.request('photo').then(response => {
  if (response === 'authorized') {
    iPhotoPermission = true;
  }
 Permissions.request('contact').then(response => {
  if (response === 'authorized') {
    iPhotoPermission = true;
  }
});
});

could grant multiple permissions at once. Is it possible to do this without using react-native-permissions?

VK1
  • 1,676
  • 4
  • 28
  • 51
  • 2
    With iOS you are going to have to show an alert for every permission that you request. It's nothing to do with the dependency that you are using it is to do with iOS itself. When you perform the request for permission in native code on iOS it triggers the alert. – Andrew Mar 11 '19 at 08:49

1 Answers1

0

Try this library for the checkbox on alert:

https://www.npmjs.com/package/react-native-awesome-alert

Vikram Biwal
  • 2,618
  • 1
  • 25
  • 36