8000 Asking several permissions · Issue #10 · sanukin39/UniAndroidPermission · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Asking several permissions #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tsequier opened this issue May 29, 2017 · 4 comments
Open

Asking several permissions #10

Tsequier opened this issue May 29, 2017 · 4 comments

Comments

@Tsequier
Copy link

Hello ! I tried asking several permissions in a row (for exemple External storage and Camera) but I can't find a way, there is alway an issue like some permission request getting skipped....
How can I do that using your plugin ?

Thanks !

@sanukin39
Copy link
Owner

Hi, Tsequier,

This is a one way to ask permission request in a row. Please try it.

  1. set permission you want to ask in a queue.
  2. call first permission request and set callback that request next permissions.
  3. Continue to the end

Sample Code

    public Queue<AndroidPermission> permissionQueue = new Queue<AndroidPermission>();
    public Action allPermissionRequested;

    void RequestPermissions(){
        permissionQueue.Enqueue (AndroidPermission.ACCESS_COARSE_LOCATION);
        permissionQueue.Enqueue (AndroidPermission.CAMERA);
        permissionQueue.Enqueue (AndroidPermission.WRITE_EXTERNAL_STORAGE);

        allPermissionRequested = () => {
            // action for all permission requested!!
        };

        RequestPermission ();
    }

    void RequestPermission(){
        if (permissionQueue.Count > 0) {
            var p = permissionQueue.Dequeue ();
            UniAndroidPermission.RequestPremission (p, RequestPermission, RequestPermission);
        } else {
            allPermissionRequested ();
        }
    }

note
Once you request permission, the second time you only have to change it by android setting.

thanks,

@Tsequier
Copy link
Author

Thanks for your answer, I'll try that !

@dave8172
Copy link
dave8172 commented Jun 16, 2017

Hi, this is not working. After asking for 1st permission, nothing is coming and app is stuck. If i close and reopen the then the next permission is coming up and so on. Can you solve this issue ?

Edit : *I seemed to have found a workaround by adding some delay in between asking permissions. It works well. Without using Queue, I am just calling the UniAndroidPermission.RequestPremission subsequently with 1 second delay in a Co-routine.

@nastyaBond92
Copy link

Hi, for me Co-routine doesn't work. But I found another way.
I call the RequestPermission() in Awake() and call all permissions one after another.

My code.

`private void Awake()
{
RequestPermission();
}

public void RequestPermission()
{
    UniAndroidPermission.RequestPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE, OnAllow, OnDeny, OnDenyAndNeverAskAgain);
    if (UniAndroidPermission.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE) || !(UniAndroidPermission.IsPermitted(AndroidPermission.WRITE_EXTERNAL_STORAGE)))
    {
        UniAndroidPermission.RequestPermission(AndroidPermission.CAMERA, OnAllow, OnDeny, OnDenyAndNeverAskAgain);
        if (UniAndroidPermission.IsPermitted(AndroidPermission.CAMERA) || !(UniAndroidPermission.IsPermitted(AndroidPermission.CAMERA)))
        {
            UniAndroidPermission.RequestPermission(AndroidPermission.ACCESS_FINE_LOCATION, OnAllow, OnDeny, OnDenyAndNeverAskAgain);
        }
    }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0