App Bridge Scanner API | Back button does not work correctly.

TwistedTree
Shopify Partner
1 0 0

Hi all,

I posted an issue here but I haven't had any response:
https://github.com/Shopify/shopify-app-bridge/issues/345

Using this API: https://shopify.dev/docs/api/app-bridge-library/apis/scanner

In the mobile app if you trigger opening the scanner, say with a button press, but do not scan a barcode. And you click the back button at the top left of the screen to close the scanner, the next time the app opens the scanner, 2 scanners will open. This continues, if you close those 2 by pressing back and open another, 3 will open.

WhatsApp Image 2024-05-16 at 12.47.45.jpeg

To Reproduce

Steps to reproduce the behaviour:

 

1. Run a simple app for example:

 

import { Button } from '@shopify/polaris';

export default function TestForm() {
return (
  <div>
    <Button
    onClick={async () => {
      try {
        const payload = await shopify.scanner.capture();
        console.log('Scanner success', payload);
      } catch (error) {
        console.log('Scanner error', error);
      }
    }}
    >press me</Button>
  </div>
);
}


2. click the "press me" button to see the scanner open.
3. Do not scan a barcode, just click back at the top left to close the scanner.
4. click the "press me" button again
5. you'll see 2 scanning windows open, scanning a barcode only closes 1 of them, pressing back only closes one of them (and subsequently opens an additional scanner).

 

Expected behavior

Clicking back should close the scanner as opposed to be what seems like minimizing it. Expected behavior is to not have multiple scan windows open, always one.

The app quickly becomes unusable after closing the barcode scanner a few times which is too common of an operation to ignore.


I guess my question is, how do I go about getting this fixed?

Replies 0 (0)