Permission.RequestUserPermission is not working

Hi all, currently I am working on a vr project for the Quest 2 and since I have a VOIP implementation I need the users to give my app the permission to use the microphone. When I boot the app for the first time I will get asked to set the permission - so that works just fine. BUT I got the feedback from users that they will refuse that permission at first - basically because of them not reading the prompt and a “fear” for their privacy. So now, as soon as the user is in the main menu I check if the permission was given - if not I display a dialog prompt to the user, describing why the app need the permission and for what it is used for.

Now my problem - I looked at this (Unity - Scripting API: Android.Permission.RequestUserPermission) and implemented it like its shown.
So the check works as intended, displaying the prompt whenever I refuse the permission.
But when I then press the button to open the permission dialog - the app goes black for a split-second and then just goes back to where it was.

using System.Collections; using System.Collections.Generic; using UnityEngine; #if PLATFORM_ANDROID using UnityEngine.Android; #endif

public class AndroidPermissionManager : MonoBehaviour
{
     //  Instantiate this class to be used in any other component.
     private static AndroidPermissionManager _instance = null;
     public static AndroidPermissionManager Instance
     {
         get
         {
             if (_instance == null)
                 _instance = (AndroidPermissionManager)FindObjectOfType(typeof(AndroidPermissionManager));
             return _instance;
         }
     }
#if PLATFORM_ANDROID
     private void Awake()
     {
         APIManager.Instance.OnIsLoggedIn.AddListener(CheckForPermissions);
     }
     void CheckForPermissions()
     {
         if(!GetMicPermission())
         {
             MenuManager.Instance.OpenMicPermissionMessage();
         }
     }
     bool GetMicPermission()
     {
         if (!Permission.HasUserAuthorizedPermission(Permission.Microphone))
         {
             return false;
         }
         else
         {
             return true;
         }
     }
     public void SetMicPermission()
     {
         Permission.RequestUserPermission(Permission.Microphone);
     }
#endif
}

TLDR I have implemented a button to set the permission in runtime but the dialog won’t open.

Is there anything I am missing? Do I need to pause the application first or is there something Quest specific I need to do to make it work?

Cheers and thanks in advance :slight_smile:

1 Like

I’m having a similar issue, did you manage to get this to work - When user initially refuses the permission and we want to request them again?

On latest Android versions if permission request is rejected twice, you can’t request it anymore.
There also was a bug in Unity that if permission was rejected by dismissing the dialog (not the Deny button), permission will not be requested again, so make sure you are on the version where this is fixed.

1 Like

I had a minor error in my code, seems to be working now!
Additionally, I’ve made a UI Panel which shows the user how to navigate to settings & grant the permission manually, when Permission Not Granted is detected.