Over17 / UnityAndroidPermissions

Unity Android Runtime Permissions for Android Marshmallow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No permission dialog

STARasGAMES opened this issue · comments

commented

I using very simple script to request permission, but I always getting permissionDenied callback. Also IsPermissionGranted always return false, even when I set permission in application settings.
App built with 26 API, and I have installed firebase messaging plugin, that uses custom activity. Tested with meizu U10, maybe problem with flyme.

What I doing wrong?

private static string[] PERMISSIONS =
    {
        "INTERNET",
        "ACCESS_NETWORK_STATE",
        "READ_PHONE_STATE",
        "ACCESS_WIFI_STATE",
        "ACCESS_FINE_LOCATION",
        "ACCESS_COARSE_LOCATION",
    };

    private IEnumerator Start()
    {
#if UNITY_ANDROID //&& !UNITY_EDITOR
        foreach (string p in PERMISSIONS)
        {
            if (!AndroidPermissionsManager.IsPermissionGranted(p))
            {
                Debug.Log("No permission: '" + p + "'\nRequest for permission. " + Time.frameCount);
                bool granted = false;
                bool gotCallback = false;
                AndroidPermissionsManager.RequestPermission(new string[] { p }, new AndroidPermissionCallback(
                    grantedPermission =>
                    {
                        gotCallback = true;
                        granted = true;
                    },
                    deniedPermission =>
                    {
                        gotCallback = true;
                        granted = false;
                    }
                    ));

                while (gotCallback == false)
                    yield return null;
                if (granted)
                {
                    Debug.Log("Permission '" + p + "' is granted. " + Time.frameCount);
                }
                else
                {
                    Debug.Log("Permission '" + p + "' is denied! " + Time.frameCount);
                }
            }
        }
#endif
        
    }

I can think of 2 possible problems:

  1. You have to add the permission to the Manifest as well, dont forget that
  2. You have at some point denied the permission and checked "[X] Dont ask again", so to revert that you have to open Settings -> Apps -> your app -> then change the permission there
commented

Sorry, Im a bit stupid XD
I just missed "android.permission." for all permissions.
"android.permission.INTERNET"

But now IsPermissionGranted always returns TRUE on U10. On Samsung with Android 7 and 8 all works fine.

INTERNET is not a dangerous permission, no dialog is needed, it's granted automatically.
https://developer.android.com/guide/topics/permissions/overview#permission-groups