Solved

APP::ERROR::UNSUPPORTED_OPERATION for recent React App Bridge with Scanner components.

keiraarts
Shopify Partner
52 7 9

Hello! I have an app using Shopify's Scanner component that's throwing an error when users have a disabled camera permissions.

Shopify's documentation suggests I request camera permissions but it's throwing an error for all 2.0.0 and higher Shopify App Bridge libraries.

The documentation being followed here
https://shopify.dev/apps/tools/app-bridge/actions/features

 

// Official documentation snippet
var features = Features.create(app);
features.subscribe(Features.Action.REQUEST_UPDATE, function (payload) {
  if (payload.feature[Scanner.Action.OPEN_CAMERA]) {
    var Dispatch = payload.feature[Scanner.Action.OPEN_CAMERA].Dispatch;
    console.log("Camera Scanner has been ".concat(Dispatch ? "enabled" : "disabled"));
  }
});

features.dispatch(Features.Action.REQUEST, {
  feature: Group.Scanner,
  action: Scanner.Action.OPEN_CAMERA
});

 


When opening Shopify's app with camera permissions disabled these are the available dispatch and subscription actions available to the app.

 

Scanner: Object
APP::SCANNER::CAPTURE: Object
Dispatch: false
Subscribe: true
APP::SCANNER::OPEN::CAMERA: Object
Dispatch: false
Subscribe: false
CAPTURE: Object
Dispatch: false
Subscribe: true
OPEN::CAMERA: Object
Dispatch: false
Subscribe: false

 


Scanner Open::Camera actions are disabled so I follow the documentations' example and request the features to be enabled. Feature requests appear to be allowed.

 

Features: Object
REQUEST: Object
Dispatch: true
Subscribe: false

 


However, Shopify's App Bridge fails here. Even though I have the permissions to request new features it'll throw an error.

 

var features = Features.create(app);

features.dispatch(Features.Action.REQUEST, {
  feature: Group.Scanner,
  action: Scanner.Action.OPEN_CAMERA
});
Uncaught AppBridgeError: APP::ERROR::UNSUPPORTED_OPERATION

 

I've tried all of the alpha packages on Shopify's libraries and this error continues to appear when requesting app permissions. 

Can anyone share a working code snippet of requesting camera functionality? 

 

Head of space operations on the Shopify moon-base.
Building orderediting.com, viaGlamour.com, magicsoaps.ca
Accepted Solution (1)
gutivg
Shopify Staff (Retired)
2 1 0

This is an accepted solution.

Thanks for the information @keiraarts. This seems to be a compatibility issue. While future versions of the app should address this issue, the current workaround you can try is to set the action to be "OPEN::CAMERA". The code would look like this:

 

var features = Features.create(app);

features.dispatch(Features.Action.REQUEST, {
  feature: Group.Scanner,
  action: "OPEN::CAMERA"
});

 

 Let me know if this solves the issue.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 5 (5)

gutivg
Shopify Staff (Retired)
2 1 0

Hey @keiraarts 

We will need more context to help you. Are you running this on the Shopify Mobile app? If so, can you also provide the version of iOS and Shopify Mobile you're using?

To learn more visit the Shopify Help Center or the Community Blog.

keiraarts
Shopify Partner
52 7 9

I am! IOS 14.5, Shopify mobile app version is 9.31.0. @gutivg 

Head of space operations on the Shopify moon-base.
Building orderediting.com, viaGlamour.com, magicsoaps.ca
gutivg
Shopify Staff (Retired)
2 1 0

This is an accepted solution.

Thanks for the information @keiraarts. This seems to be a compatibility issue. While future versions of the app should address this issue, the current workaround you can try is to set the action to be "OPEN::CAMERA". The code would look like this:

 

var features = Features.create(app);

features.dispatch(Features.Action.REQUEST, {
  feature: Group.Scanner,
  action: "OPEN::CAMERA"
});

 

 Let me know if this solves the issue.

To learn more visit the Shopify Help Center or the Community Blog.

keiraarts
Shopify Partner
52 7 9

It works for ios - genuinely very thankful you helped me! My app has been stuck in review for weeks!

Will this be a code snippet I can leave through future releases of Shopify's App Bridge?

Head of space operations on the Shopify moon-base.
Building orderediting.com, viaGlamour.com, magicsoaps.ca
andrew-apperley
Shopify Staff (Retired)
21 5 4

Hey @keiraarts ,

Yes you will be able to keep this snippet in your codebase with future versions because the solution @gutivg alluded to that we are working on will include backwards compatibility.

To learn more visit the Shopify Help Center or the Community Blog.