Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Interpreting "Ask every time" as "denied" #284

Open
mxavierneowrk opened this issue Aug 17, 2023 · 1 comment
Open

Interpreting "Ask every time" as "denied" #284

mxavierneowrk opened this issue Aug 17, 2023 · 1 comment

Comments

@mxavierneowrk
Copy link

Describe the bug
On Android when asking for permission users has three options:

  1. Allow only while using the app
  2. Ask every time
  3. Don't allow

When users select the second option "Ask every time" we should ask every time if it allows, but it is assuming as "denied" directly.

To Reproduce
Steps to reproduce the behavior:

  1. Ask users for permission
  2. Select the option "Ask every time"
  3. Close the app
  4. Go to app settings and change the permission to "Don't allow" and back to "Ask every time"
  5. Open the app again
  6. Ask users for permission

Expected behavior
It should ask for permission again because the options selected is "Ask every time"

Current behavior
The result comes straight as denied

Screenshots
The option "Ask every time" is selected:
image

When checking camera permissions it is returning denied as true:
image

Version
^4.0.0

Smartphone:

  • Device: Moto g(60)s
  • OS: Android 12

Additional context
This is the code that we are using:

public async cameraHasPermission(): Promise<boolean> {
        // check if user already granted permission
        const status = await BarcodeScanner.checkPermission({ force: true });

        alert(`{ force: true } -- Status: ${JSON.stringify(status)}`);

        if (status.granted) {
            // user granted permission
            return true;
        }

        if (status.denied) {
            // user denied permission
            await this.openCameraSettings();
            return false;
        }

        if (status.asked) {
            // system requested the user for permission during this call
            // only possible when force set to true
        }

        if (status.neverAsked) {
            // user has not been requested this permission before, we will prompt
            // a message asking for the permission
            const confirmed = confirm(await this.translationService.translateAsPromise(PermissionsTranslateKey.confirmCameraPermission));
            if (!confirmed) {
                await this.openCameraSettings();
                return false;
            }
        }

        if (status.restricted || status.unknown) {
            // ios only, probably means the permission has been denied
            await this.openCameraSettings();
            return false;
        }

        // user has not denied permission
        // but the user also has not yet granted the permission
        // so request it
        const statusRequest = await BarcodeScanner.checkPermission({ force: true });

        alert(`{ force: true } -- Status: ${JSON.stringify(statusRequest)}`);

        if (statusRequest.granted) {
            // the user did grant the permission now
            return true;
        }

        // user did not grant the permission, so he must have declined the request
        await this.openCameraSettings();
        return false;
    }
@roboter
Copy link

roboter commented Aug 27, 2023

I have same bug
First time user select ask every time everything is correct and scanner works
second time no asking and blank screen, in logs I got "No Permission to use Camera"

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

No branches or pull requests

2 participants