Skip to content
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

Unable to open scanner in embedded remix app. #288

Closed
SuryanshuTiwari opened this issue Feb 16, 2024 · 0 comments
Closed

Unable to open scanner in embedded remix app. #288

SuryanshuTiwari opened this issue Feb 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SuryanshuTiwari
Copy link

SuryanshuTiwari commented Feb 16, 2024

I have been working on a project where I need to implement shopify scanner. I have tried both lagacy API and the new api but to no avail.

I am using Remix and the app is embedded.

This is my code

import {Group, Scanner, Features} from '@shopify/app-bridge/actions';

config = {
        apiKey: 'apiKey',
        host: new URLSearchParams(window.location.search).get("host"),
        forceRedirect: true
    };

var app = createApp(config);

var features = Features.create(app);

features.subscribe(Features.Action.REQUEST_UPDATE, function (payload) {
          if (payload.feature[Scanner.Action.OPEN_CAMERA]) {
            var available = payload.feature[Scanner.Action.OPEN_CAMERA].Dispatch;
            // If the Camera Scanner actions were enabled, open a Scanner
            if (available) {
              scanner.dispatch(Scanner.Action.OPEN_CAMERA)
            }
          }
        });
        // Dispatch an action to request access to Scanner actions
        features.dispatch(Features.Action.REQUEST, {
          feature: Group.Scanner,
          action: Scanner.Action.OPEN_CAMERA
        });

When I console.log('handleClick',Scanner.Action.OPEN_CAMERA);

This is what I get

handleClick APP::SCANNER::OPEN::CAMERA

For some reason the console.log inside the features.subscribe is not printing anything.

Any help is greatly appreciated.

@SuryanshuTiwari SuryanshuTiwari added the bug Something isn't working label Feb 16, 2024
@SuryanshuTiwari SuryanshuTiwari changed the title Unable to open scanner from remix app. Unable to open scanner in embedded remix app. Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant