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?