Create a link that either launches iOS app, or redirects to app store [duplicate]

浪子不回头ぞ 提交于 2019-11-27 18:04:22

问题


Possible Duplicate:
Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

I have a custom URL scheme for my iOS app, and I want to be able to email a link to someone that will either launch the app if it's on the device, or take them to the app store if they don't have it.

I'd like to be able to send myapp://someurl and have that either launch or go to myapp on the appstore, but I don't think this will work out of the box.

Instead, I'm thinking of creating a link that loads some javascript which will try myapp://someurl, and if that fails will instead load the app store link.

My javascript knowledge is crappy. I can set window.location to perform the redirect, but there doesn't seem to be a way to catch errors from that in order to perform another action if that fails.

Anyone know how to do this?


回答1:


 window.launchsockPicker = function() {
       setTimeout(function() {
        window.location = 'http://myDomain.com/install-app.cfm'
       }, 500);

       window.location = 'myApp://?context=someVariableIfNeeded';
   };



回答2:


There is no good way to achieve this. You can launch an app via a URL but there is no way to test whether an app is installed first.



来源:https://stackoverflow.com/questions/4671634/create-a-link-that-either-launches-ios-app-or-redirects-to-app-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!