Skip to main content

POS

Note

This is a legacy API. Use the latest version of POS instead.

Provides a mechanism for closing the app when it's running in Shopify POS, and for retrieving information about a Shopify POS device.


  • User and location data are available in all version of Point of Sale Android and iOS.
  • Device data is available in following app version:
    • Point of Sale iOS version 5.36.0 or above
    • Point of Sale Android version 3.29.0 or above
  • Close is available in the following app version:
    • App Bridge version 1.18.0 or above is required
    • Point of Sale iOS version 5.50.0 or above
    • Point of Sale Android version 3.43.0 or above

Create an app and import the Pos module from @shopify/app-bridge/actions. Note that we'll be referring to this sample application throughout the examples below.

Note

In the following example, config is a valid App Bridge configuration object. Learn more about configuring App Bridge.

import createApp from '@shopify/app-bridge';
import {Pos} from '@shopify/app-bridge/actions';

const app = createApp(config);

Anchor to Close an app embedded in Shopify POSClose an app embedded in Shopify POS

Create a Pos object that can be used to close the embedded app. You might close the embedded app after the user successfully completes an action to return them to the Shopify POS app.

const pos = Pos.create(app);

To close the embedded app, use the Pos object to dispatch the CLOSE action.

// App Bridge 1.x
pos.dispatch(Pos.ActionType.CLOSE);

// App Bridge 2.x
pos.dispatch(Pos.Action.CLOSE);

POS data is available in the state and accessible through app.getState(). There are several ways to get the data:

Option 1: get all state

app.getState().then((data) => {
const {pos} = data;
});

Option 2: get only pos

app.getState('pos').then((pos) => {
});

Option 3: get only pos user

app.getState('pos.user').then((user) => {
});

Option 4: get only pos location

app.getState('pos.location').then((location) => {
});

Option 5: get only pos device

app.getState('pos.device').then((device) => {
});
Note

app.getState() just returns current state. To avoid getting state before it is ready, you may need to subscribe as below:

const unsubscribe = app.subscribe(function() {
app.getState('pos').then(function(pos) {
if (!pos) {
return;
}
unsubscribe();
});
});

KeyTypeDescription
userUserUser info.
locationLocationLocation info.
deviceDeviceDevice info.

KeyTypeDescription
idNumberThe ID of login user.
firstNameStringThe first name of login user.
lastNameStringThe last name of login user.
emailStringThe email name of login user.
accountOwnerBooleanIndicate if login user is the shop owner.
userTypeStringThe type of login user.

KeyTypeDescription
idNumberThe ID of current location.
activeBooleanThe status of current location.
nameStringThe name of current location.
locationTypeString?The type of current location.
address1String?The primary address of current location.
address2String?Any extra information associated with the address (Apartment #, Suite #, Unit #, etc.).
zipString?The ZIP or postal code of the address.
cityString?The name of the city.
provinceString?The province or state of the address.
countryCodeString?The Country Code in ISO 3166-1 (alpha-2) format.
countryNameString?The country of the address.
phoneString?The phone number of the location.

KeyTypeDescription
nameStringThe name of the device
serialNumberStringThe unique ID associated device ID and app ID.

Was this page helpful?