0

Let's try to make an example that would make most sense to explain my problem. Let's say I have my app available on example.com and also created few universal links like example.com/application that when clicked from a phone device open inside the app if it's installed. This works fine.

Now can I make subdomain, something like app.example.com where if you click on it, it will also open inside the application. So pretty much any path from app.example.com/* should open within the app if installed.

What would be the process of doing this. Do I have to create a subdomain, can this be done from from adding associated domains, how would my apple-app-site-association file look?

I know my question is a big vague, but just looking at some starting pointers or documentation around doing this. Hopefully it's enough for someone to give some advice

vukojevicf
  • 609
  • 1
  • 4
  • 22
  • The documentation at https://developer.apple.com/documentation/xcode/supporting-associated-domains seems to cover how to handle subdomains. – HangarRash Apr 02 '23 at 17:53

2 Answers2

0

I am using this JSON inside my apple-app-site-association file.

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "your appID and bundle identifier",
                "paths": ["*", "/*"]
            }
        ]
    }
}

you can also check this example (by Apple) for adding subdomains in your apple-app-site-association file.

{
  "applinks": {
      "details": [
           {
             "appIDs": [ "ABCDE12345.com.example.app", "ABCDE12345.com.example.app2" ],
             "components": [
               {
                  "#": "no_universal_links",
                  "exclude": true,
                  "comment": "Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link."
               },
               {
                  "/": "/buy/*",
                  "comment": "Matches any URL with a path that starts with /buy/."
               },
               {
                  "/": "/help/website/*",
                  "exclude": true,
                  "comment": "Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link."
               },
               {
                  "/": "/help/*",
                  "?": { "articleNumber": "????" },
                  "comment": "Matches any URL with a path that starts with /help/ and that has a query item with name 'articleNumber' and a value of exactly four characters."
               }
             ]
           }
       ]
   },
   "webcredentials": {
      "apps": [ "ABCDE12345.com.example.app" ]
   },

    "appclips": {
        "apps": ["ABCED12345.com.example.MyApp.Clip"]
    }
}

for more information, you can check on this link: https://developer.apple.com/documentation/xcode/supporting-associated-domains

Jaipee1
  • 76
  • 7
0

It's possible. Deep link domains and applications are in many-to-many relation. Each of your domains should provide association manifest that mentions each of your apps that can work with links on that domain.

If you have two domains example.com and app.example.com and a single application, then both of these links:

should point to a file like that (replace XXXXXXXXXX.com.example.app with actual app id):

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appIDs": [
                    "XXXXXXXXXX.com.example.app"
                ],
                "paths": [
                    "*"
                ],
                "components": [
                    {"/": "/*"}
                ]
            }
        ]
    },
    "webcredentials": {
        "apps": [
            "XXXXXXXXXX.com.example.app"
        ]
    }
}

In your iOS project Entitlements.plist, you should add each of your domains explicitly:

<plist version="1.0">
<dict>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
        <string>webcredentials:example.com</string>
        <string>applinks:app.example.com</string>
        <string>webcredentials:app.example.com</string>
    </array>
...

or using a wildcard:

<plist version="1.0">
<dict>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
        <string>webcredentials:example.com</string>
        <string>applinks:*.example.com</string>
        <string>webcredentials:*.example.com</string>
    </array>
...
fedulvtubudul
  • 341
  • 3
  • 6