Shopify POS SDK Error

Highlighted
Excursionist
42 1 4

We are developing one module useful for shopify POS customers.

What we are doing is including the shopify pos SDK js and normally try to fetch cart.

But sometimes cart is retrieved and sometimes it is not.

It is not going in error function as well.

we read documentation here -> https://help.shopify.com/en/api/embedded-apps/shopify-pos-app-sdk/methods#cart-fetch

 

We don't know what is going on and how to solve this issue.

 

Any help will be awesome in this case.

0 Likes
Shopify Staff
Shopify Staff
1552 77 232

Are any other POS SDK methods working in the context where you are calling fetchCart? I'm wondering if maybe there's an issue with the SDK initializing in some cases.

0 Likes
Excursionist
42 1 4

Hey @Alex ,

 

Thank you for replying.

 

We are initializing in this way. 

As per documentation here -> https://help.shopify.com/en/api/embedded-apps/shopify-pos-app-sdk/methods#pos-initialize

 

ShopifyPOS.init({"apiKey":"xxxxxxxxxxxxxx","shopOrigin":"https://gunjan-test6.myshopify.com","forceRedirect":true});

Does forceRedirect is required? Why there is no documentation on that?

 

One more thing i noticed is it is not going in  ready function.

ShopifyPOS.ready(function(){
  alert("Ready");
});

If it goes to ready event it work perfectly.

But if it is not then nothing works. 

 

There is one parameter called debug. 

I personally don't find it useful as there is no console to print. 
How we can use that debug and test our application easily?

 

Do we need to put initializing function into the ready function? or it will work our side the ready?

It's confusing for me now since last 3 days i am trying to solve this issues.

 

Thank you

0 Likes
Shopify Staff
Shopify Staff
1552 77 232

forcedRedirect is not required and its default value is true. It's worth noting though that you should only be setting it to false for debugging purposes, since most times you'll want to be following the redirect into an admin context. ShopifyPOS.ready is necessary to ensure that both the admin context and your app's view are completely loaded before calling the methods, both of which are required so it's generally a good idea to call method in there.

 

ShopifyPOS.init can be called outside of ready since it's necessary to get you into that required admin context in the first place. The documentation is admittedly not great, and the goal at the end of the day is to migrate existing consumers of the SDK to App Bridge instead.

0 Likes
Excursionist
42 1 4
Okay great so i can integrate POS with App bridge? If it so please send me link for that. So that i can read documentation and make it work.
0 Likes
Shopify Staff
Shopify Staff
1552 77 232

I should have been a bit more clear and I spoke a little too soon. While to goal is to migrate folks to App Bridge, we don't currently offer the methods needed to migrate from the POS app SDK. That's the nearest possible future plan though.

0 Likes
Excursionist
42 1 4

@Alex So what should we do? 

AS we have invested more than 20 days for this feature and now we are unable to launch it.

 

Is there any workaround to this issue?

This is really sad 😔😢 ☹️ .

0 Likes
Shopify Staff
Shopify Staff
1552 77 232

I cannot replicate this personally so it's difficult to troubleshoot from my end. Under ideal circumstances, you would be able to pipe your JS console output to a mac running safari but this appears to have been removed as a security measure by Apple themselves on production builds of iOS apps (assuming you're using iOS, I'm not sure exactly how or if Android does this with Chrome).

 

You could try to do a check to see if ShopifyPOS is even loaded and surface that via jquery like so:

 

if (ShopifyPOS){ $("#some-element-by-id").html("ShopifyPOS is loaded") };

If ShopifyApp is not loaded then at least we're closer to the root of the issue.

 

Cheers.

0 Likes
Excursionist
42 1 4

hey @Alex ,

 

I have added code as per your reply.

Please check following two videos in which one is working like charm and other is not working.

The latest event will be on top of ul(I have prepended li in ul).

 

1. Working Video Link

2. Not Working Video Link.

 

The json data appears that is used to call init event for ShopifyPOS.

{"apiKey":"00c55d43f7......","shopOrigin":"https://gunjan-test6.myshopify.com","forceRedirect":true}

0 Likes
Shopify Staff
Shopify Staff
1552 77 232

How often would you say this occurs for you? I'm hitting the success callback each time I've been trying in my tests interestingly enough.

0 Likes