App Bridge Toast duration parameter does nothing

Solved
policenauts
Pathfinder
105 6 18

Is this a known bug? It seems to last for 5 seconds regardless of what value you input. Thank you.

0 Likes
Henry_Tao
Shopify Staff
Shopify Staff
79 25 11

Hi @policenauts 

Can you share the code? The duration should work based on what the app sets. I just tested it again on prod.

Thanks, 

0 Likes
policenauts
Pathfinder
105 6 18

Thanks @Henry_Tao. My code is just the standard app bridge toast code:

                   var  Toast = actions.Toast;
                    var toastOptions = {
                      message: "Successfully added this item to the cart!"
                      duration: 10000
                    };
                    var toastSuccess = Toast.create(app, toastOptions);
                    toastSuccess.dispatch(Toast.Action.SHOW);    

 

Here is the response from webview logging, it shows the duration being passed as a parameter but no matter what I change it to, it lasts 5 seconds. Thank you. 

	Optional Params: [{"group":"Toast","payload":{"id":"b0119af3-4cbf-40ec-2697-2ff2e7400a64","duration":10000,"message":"Successfully added this item to the cart!"},"type":"APP::TOAST::SHOW","version":"1.26.2","clientInterface":{"name":"@shopify/app-bridge","version":"1.26.2"},"source":{"apiKey":"{my api key}","shopOrigin":"{my dev store"}}]

 

0 Likes
Henry_Tao
Shopify Staff
Shopify Staff
79 25 11

I tested similar code. The toast keeps showing according to duration that I set. What's your appId? Is there anyway that I can test it on my store?

0 Likes
Henry_Tao
Shopify Staff
Shopify Staff
79 25 11

This is an accepted solution.

I think I know why. Look like your app is a POS app. That means it is mainly used in Point of Sale app. Android, iOS, and Web treat duration differently. Web respects duration (which I told you in the thread). Android Toast message only has SHORT (roughly 2s) and LONG (roughly 4s). iOS hardcode 4s to match Android. 

0 Likes
policenauts
Pathfinder
105 6 18

Thanks @Henry_Tao for the quick response. It would be great if they updated the documentation to mention that: https://shopify.dev/tools/app-bridge/actions/toast

0 Likes
Henry_Tao
Shopify Staff
Shopify Staff
79 25 11

I will create a ticket and forward to the team. Thanks for the feedback.