Take it up with Apple, on android there's an API apps can use to launch themselves for certain web requests. However, there's no way to do this with iOS.
Being able to tell whether the app is installed sounds like a privacy violation. There is a mechanism for linking to apps in iOS; Google should be using it.
Actually it fires an intent, and if the application is there it will catch it, if not, it won't. No privacy violation needed as IIRC it won't communicate back to the website.
Could be wrong, haven't done much android programming.
I don't think it's possible to do this from JavaScript. (On the other hand, no real reason Google couldn't use a Smart App Banner, which is uncustomizable but presents an appropriate UI to either install or run the app.)