Yahya Ahmed
Yahya Ahmed

Reputation: 347

React native permission, IOS: Getting "blocked" permission when user "Don't allow" Microphone permission

I am using the package react-native-permissions and looking for the solution for the following problem

Use case:

  1. On the prompt for permission for microphone for the first time, the user inputs Don't Allow
  2. Once this is done the permission status is set to blocked and as per my research the user now need to manually go to the settings and allow microphone.
  3. Upon permission change the app gets killed which I need to avoid

What should be the possible solution?

Is there a way the status can be set to denied instead of blocked, so that user can allow without leaving the app?

Upvotes: 0

Views: 1492

Answers (1)

Pratik Prakash Bindage
Pratik Prakash Bindage

Reputation: 937

  1. Unfortunately,once the user has selected "Don't Allow" for a permission request, the app cannot programmatically request the permission again without the user manually going to the device settings and granting the permission. This is a security feature implemented by the device operating system to prevent apps from repeatedly asking for permissions that the user has already denied.

  2. react-native-permissions : https://unpkg.com/browse/[email protected]/README.md#:~:text=%7C%20%60RESULTS.BLOCKED%60%20%7C%20The%20permission%20is%20denied%20and%20not%20requestable%20anymore%20%7C&text=Only%20%60Allow%20Once%60%2C%20%60Allow%20While%20Using%20App%60%20and%20%60Don't%20Allow%60

  3. Handling permissions in React Native : https://hemanthkollanur.medium.com/handling-permissions-in-react-native-c4f29cf99e7a#:~:text=The%20permissions%20dialog%20shown%20by%20the%20system,might%20find%20that%20puzzling.%20It's%20a%20good%E2%80%A6

  4. React Native: Managing App Permissions for iOS : https://rossbulat.medium.com/react-native-managing-app-permissions-for-ios-4204e2286598

  5. react-native-permissions : https://github.com/zoontek/react-native-permissions

    import * as permissions from 'react-native-permissions';
    
    const checkMicrophonePermission = async () => {
      const result = await permissions.check(permissions.PERMISSIONS.ANDROID.RECORD_AUDIO);
    
      if (result === 'denied') 
      {
        alert('Microphone permission has been denied. Please go to your device settings and grant the permission manually.');
      }
    };
    
    
    // Call the function to check the permission status
    checkMicrophonePermission();
    

Upvotes: 2

Related Questions