Solved

App Bridge Toast duration parameter does nothing

policenauts
Shopify Partner
206 10 67

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

Accepted Solution (1)
Henry_Tao
Shopify Staff
91 28 15

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. 

Henry | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 6 (6)

Henry_Tao
Shopify Staff
91 28 15

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, 

Henry | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

policenauts
Shopify Partner
206 10 67

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"}}]

 

Henry_Tao
Shopify Staff
91 28 15

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?

Henry | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Henry_Tao
Shopify Staff
91 28 15

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. 

Henry | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

policenauts
Shopify Partner
206 10 67

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

Henry_Tao
Shopify Staff
91 28 15

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

Henry | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog