Embedded app for Shopify Admin Vs POS

GuillaumeM
New Member
2 0 0

Hi,

We are facing an issue with Shopify POS on iOS.

We are trying to embed a part of our app there. Everything works smoothly if we have enabled the embedded app on Shopify POS and Shopify Admin in Shopify Partner settings.

It doesn't work if the app is only enabled for Shopify POS and we don't want to enable it on Shopify Admin as we need to know which user is using the app to redirect to the right screen (matching their profile).

 

So i was wondering if there is anyway to solve that and if Shopify POS on the partner platform is actually referring to the Android app and not the iOS app?

0 Likes
policenauts
Pathfinder
98 6 18

To distinguish between POS and admin: https://community.shopify.com/c/Shopify-APIs-SDKs/Divide-desktop-and-pos-view-on-pos-embedded-app/m-...

For iOS vs. Android and new vs. classic, this is how I do it, it works for App Bridge 1.25.0. These are hacks that I've found after much trial and error, because there is a bug in the actual properties, but it is reliable enough. Use at your own discretion and examine the actual properties across multiple devices to confirm it works for you. 

For iOS:

  const unsubscribe = app.subscribe(function() {
  app.getState('pos').then(function(pos) {
    console.log(' after subscribe, pos is ' + Object.keys(pos));

    if (('device' in pos)) { // if device property exists, it's iOS

        if (isNaN(pos.device.name)) { // this will be a number for classic
          posType = PosEnum.new 
        }
        else {
          posType = PosEnum.classic; // this will say "ipad" or iPhone for new POS
        }
}
}

 

For Android:

      app.getState().then((data) => {
       
      if (!('device' in data.pos)) { // if device property doesn't exist, it's android
      }
}

 

0 Likes