- Home /
Quest 2 - Android PermissionRequest dialog does not open
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 (https://docs.unity3d.com/ScriptReference/Android.Permission.RequestUserPermission.html) 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.
Code: 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
}
TL:DR 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 :)
Edit: typo