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

Solved
keiraarts
Shopify Partner
28 4 4

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? 

 

Accepted Solution (1)

Accepted Solutions
gutivg
Shopify Staff
Shopify Staff
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.

View solution in original post

Replies 5 (5)
gutivg
Shopify Staff
Shopify Staff
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?

keiraarts
Shopify Partner
28 4 4

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

gutivg
Shopify Staff
Shopify Staff
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.

keiraarts
Shopify Partner
28 4 4

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?

andrew-apperley
Shopify Staff (Retired)
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.

Andrew Apperley
(App Bridge) Mobile Developer