Detect Standalone mode on mobile device

I’m building a PWA, and on my sign up page, I want to show a prompt to install the app onto the home screen if it is not already installed. So I need to detect if their mobile browser is in Standalone mode or not.

I believe I can use the javascript function window.navigator.standalone – but I don’t know how to write this javascript expression.

Could someone please suggest a javascript expression I can put into the Toolbox javascript plugin?

return this statement in your toolbox action:
window.matchMedia(’(display-mode: standalone)’).matches


Thank you so much for your help @paul29

Is this how I should configure the statement in Toolbox?

Screen Shot 2022-07-12 at 5.15.06 PM

I get this error, please advise. I’m new to javascript

Thanks again for your assistance

You’re javascript should just be one line:
bubble_fn_pw(window.matchMedia(’(display-mode: standalone)’).matches)

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.