简体   繁体   中英

How do I redirect a User to the app when opening a link in Safari?

I want to redirect Users to my iOS application when they type a specific domain (one I control) in to the address bar.

I have my apple-app-site-association file:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "TEAM_ID.bundle_identifier",
        "paths": [ "*" ]
      }
    ]
  }
}

This is uploaded to my server running HTTPS, sitting inside of a .well-known directory in the root of my server.

On XCode, I have linked the Associated Domains and just added applinks:example.com (for now).

When I email myself the link and click it, my application opens perfectly. How do I extend it further to allow the app to open when clicking on a link in Safari?

I want to enable a sharing mechanism whereby a User clicks a link on Twitter Mobile Web (for example) and my application opens.

Edit: I've got URL Types set up but of course it requires a User/site to redirect to example:// - this isn't what I want to achieve.

Safari should handle Universal Links but they have a limitation of opening the app when you are already on the same domain. For example, if you are on example.com and click on a Universal Link example.com/deep/link/path . It will stay on the browser.

This is why Branch uses 2 URLs. example.app.link and example-alternate.app.link so when you click on a link when already on the website you are still taken to the app.

Also, typing a Universal Link into Safari does not work. It must be tapped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM