How can I detect whether a user has installed a specific iPhone app via JavaScript?
I'd 开发者_JAVA技巧like to build a mobile Web app that:
- If my iPhone app is already installed, launches it by redirecting to a URL handled by the app
- If my iPhone app is not installed, displays a web page encouraging users to download it from the App Store
The problem is, I don't know how to detect whether the app is installed before redirecting. Does anyone know a trick for doing this? Maybe a JavaScript hack of some sort, leveraging the App registered URL in an iframe or similar?
You very likely can't do this. Even in a native app, all you can call is UIApplication's canOpenURL: method, which just tells you if some app will open the URL, not which one. I have no idea if this function is exposed in JavaScript; very likely not (I wouldn't want malicious javascript probing my phone for which URLs it can open).
精彩评论