Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
88 stars 9 forks source link

Cart feature detection bug on AppBridge 2.0 #87

Closed rmtngh closed 6 months ago

rmtngh commented 2 years ago

Describe the bug

Following the documentation, state.Cart object is expected to have keys defined in app-bridge/actions/Cart, but they keys are different resulting in error and never successfully detecting the cart feature.

app.featuresAvailable(Group.Cart).then(function (state) {
  var _ref = state.Cart && state.Cart[Cart.Action.FETCH], // <---------
  Dispatch = _ref.Dispatch;
...
});

_ref is undefined, value of Cart.Action.FETCH from "@shopify/app-bridge": "2.0.5" is: APP::CART::FETCH while in the returned value from featuresAvailable the object key is: FETCH

Actual result: FETCH: { Subscribe: true, Dispatch: true }

Expected result: "APP::CART::FETCH": { Subscribe: true, Dispatch: true }

To Reproduce

Steps to reproduce the behaviour:

  1. Follow feature detection instructions from here with the latest version of @shopify/app-bridge
  2. Launch app on Shopify POS app v6.71.0
  3. Cart feature is not available

Expected behaviour

Cart feature needs to be returned as available when an app is launched from Home view on Shopify POS

Contextual information

Packages and versions

List the relevant packages you’re using, and their versions. For example:

Platform

Additional context

ZainManji commented 2 years ago

I noticed this as well... As for now, I hardcoded the keys in the code, e.g. "FETCH", instead of using Cart.ActionType.FETCH (which translated to APP::CART::FETCH)

charlesdobson commented 6 months ago

Closing as outdated as the POS APIs have been updated in the latest version of App Bridge: https://shopify.dev/docs/api/app-bridge-library/apis/pos. Please reopen if you're still having the issue!