iosswiftdeep-linkingaasa

I have uploaded apple-app-site-association on my server, which I use for backend services


Where can I upload 'apple-app-site-association' for universal link setup in my iOS app?.

How can I use universal link in my iOS app?. I am getting just confuse to read a lot of tutorials. Can anyone help me?


Solution

  • You need to upload apple-app-site-association file to the root directory of the server(from where you need to redirect to your installed app).

    e.g- Suppose you have to redirect from www.abc.com/getapp then you need to upload the apple-app-site-association file to the root directory where the www.abc.com is get hosted.

    Steps to support universal links-

    1. Create your apple-app-site-association file(Suppose your universal link is www.abc.com/getapp and you want to redirect in your app from here).

      {
       "applinks": {
          "apps": [],
          "details": [
              {
                  "appID": "9JA89QQLNQ.com.apple.wwdc", //9JA89QQLNQ is your team ID & com.apple.wwdc is your bundle id
                  "paths": [ "/getapp"]
              }
          ]
        }
      }
      
    2. Upload this file to the root directory where www.abc.com is hosted.

    3. Validate at http://branch.io/resources/aasa-validator/. If the file is valid then all checks would be green.
    4. Now prepare your app to support universal links-

      a. Go to developer.apple.com and enable Associated Domains to your app ID.

      b. Select your target and turn on Associated Domains switch.

      c. Add applinks:abc.com. enter image description here

      d. Add application:continueUserActivity:restorationHandler: app delegate method so that your app can receive a link and handle it appropriately.

    Not getting callback to the app-

    1.When a user is browsing your website in Safari and they tap a universal link to a URL in the same domain as the current webpage, iOS respects the user’s most likely intent and opens the link in Safari. enter image description here

    2.Copy and paste your universal link(http(s)://www.abc.com/getapp) to notes and tap on it. It your app can handle this link you will get the option Open in "AppName".

    References-

    1. https://gist.github.com/anhar/6d50c023f442fb2437e1
    2. https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html

    Hope it may help.