James
James

Reputation: 1407

Tell if WebApp launched via URL or link on iPhone home screen

Is there a way of telling whether my Web Application has been launched from a button on the user's iPhone home screen? I want to display a "add this WebApp to your home screen" prompt if the user has accessed the WebApp via safari by typing in a URL.

Upvotes: 9

Views: 4595

Answers (4)

GeoNomad
GeoNomad

Reputation: 769

window.navigator.standalone

True if you have launched from the Home Screen. False if in the Safari browser.

Documented here:

https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

It works with OS 2.1 and up.

Upvotes: 25

ceejayoz
ceejayoz

Reputation: 180004

jQTouch detects this (try the demo). It's open source, so you should be able to find out how.

Upvotes: 1

Matt S.
Matt S.

Reputation: 13753

If I remember correctly there's a thing in the server log that shows what the user's previous page was. So the only way I can think of is if the user was on a previous page display the "add" thing, and if they didn't don't

Upvotes: 0

rpetrich
rpetrich

Reputation: 32316

In Safari, the scrollY will start at a negative value if inside Safari, and at 0 if running as an application.

Likely the viewport will change as well (if it does, this is a more reliable method)

Upvotes: 2

Related Questions