1

I recently bought an iPod so that I could test my own HTML5 games on iOS, and while looking around I found this HTML5 app:

http://www.apple.com/webapps/games/goldnuggets.html

If you load that page from an iPod or iPhone, you'll be able to play the game.

What I found memorable about this app is that when you try to load it, it forces you to 'install' (save) it to your homepage before you can play. The benefit of this is that the HTML5 app gets the full screen area to work with when launched from the homepage, just like a normal iOS app (as opposed to being covered up with the address bar and that command bar at the bottom).

I was wondering how I can check if the app has been added to the homepage (not the actual "add to homepage" function - which according to this thread is not possible Javascript for "Add to Home Screen" on iPhone?).

I could certainly use an extra 100px, and it would allow me to easily create an iOS version and HTML5 version with matching interfaces, and a better user experience.

Any ideas? Google search turned up nothing for me.

Community
  • 1
  • 1
Matthew
  • 451
  • 1
  • 6
  • 14

2 Answers2

4

TL;DR window.navigator.standalone

And everything you need at http://www.bennadel.com/blog/1950-Detecting-iPhone-s-App-Mode-Full-Screen-Mode-For-Web-Applications.htm

Good luck!

Matijs
  • 3,118
  • 2
  • 29
  • 41
0

One thought is to add a bookmark/favorite via JavaScript (called from an onclick event):

window.external.AddFavorite( url + "?somevariablethatsaysitisok=true", "MyGameName");

which I assume would work for iOS Safari as well.

On the URL part of it you can pass an argument that, when set, would allow the game to be played. If not set then only show the book mark link

You can either browser detect serverside or, if I remember correctly use javascript's navigator.userAgent or navigator.appVersion to see if it contains iPhone / iOS. Of course I would do some testing to to make sure you get the exact string, but that's the general idea.

ToddBFisher
  • 11,370
  • 8
  • 38
  • 54
  • I actually just read this: "The only way to add any book marks in MobileSafari (including ones on the home screen) is with the builtin UI, and that Apples does not provide anyway to do this from scripts within a page. In fact, I am pretty sure there is no mechanism for doing this on the desktop version of Safari either." – Matthew Mar 06 '12 at 06:35
  • I changed my question, asking how to actually check if the game has been added to homepage. – Matthew Mar 06 '12 at 06:35