Redirect to application if installed, otherwise to App Store

后端 未结 8 2545
渐次进展
渐次进展 2020-12-02 04:52

I know it\'s possible to link directly to an app in iOS by registering a custom scheme (e.g. so://) and it\'s also possible to link to the app in the appstore via itunes.

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 05:07

    There is no way to check for this. However, there is a nice workaround.

    The idea is basically this:

    1. The first time you open your app, you open up mobile safari from within your app to a predefined URL on your server
    2. On that URL you set up a cookie, like appInstalled to the users mobile safari
    3. You then kick the user back to your app with your registered scheme (same as FB does with SSO)
    4. All your email links point to your website, but on the website you check if the browser is mobile Safari and if the appInstalled cookie exists
    5. If either the browser is not mobile Safari or the cookie is not found, you redirect to the AppStore, or stay in your webpage.
    6. If the conditions of #4 are true, you redirect the user to your app with the registered scheme
    7. If the app has been deleted by the user, so the custom url scheme fails, you have a fail-safe redirect to the appstore

    The 2 last steps are explained on this SO post

提交回复
热议问题