Universal Links to multiple apps

I have successfully implemented Universal Links so that a visitor to specific URLs on our site is redirected to one of our apps. It all works well. Alarmingly well, in that it all worked perfectly first time. (I blame the documentation).

A question I can't find specifically addressed in the documentation is: what if we have two apps that can both handle a given link? This is in fact our situation.
  1. In most cases users will have one or other of the apps installed. The correct behaviour would then be to direct the user to the installed app.

  2. In some cases the user will have both apps installed. In that case the ideal behaviour would be to direct the user to what we have defined to be the "main" app.

It looks to me as if it is possible to two apps in an apple-app-site-association file, but not having found this in the documentation, I wonder: has anyone on here actually tried this? Did it work as expected?
Answered by Vision Pro Engineer in 782762022

Hi all, if you're running into this post looking for a way to open multiple apps from the same AASA, please refer to @Frameworks Engineer 's answer except using the key "components" instead of "patterns". Eg:

	"applinks": {
		"details": [{
			"comment": "Veggies is listed first.",
			"appIDs": [ "0123456789.com.example.veggies" ],
			"components": [
				{ "/": "/nom-nom/*" }
			]
		},
		{
			"comment": "Fruits is listed second, and is only consulted if the first section didn't match anything on the user's device.",
			"appIDs": [ "0123456789.com.example.fruits" ],
			"components": [
				{ "/": "/nom-nom/*" },
				{ "/": "/fruits-but-not-veggies/*" }
			]
		}]
	}
}

With this change to "components" instead of "patterns", you should be able to match to certain components of a link even for 2 separate apps

Hi Universalis! It is possible to specify associated domains data for multiple applications. The system will walk the data in the order it appears in your apple-app-site-association file. So, for instance, if you have two apps, "0123456789.com.example.fruits" and "0123456789.com.example.veggies", and what to preferentially open universal links in "Veggies", you'd write something like this:

Code Block json
{
"applinks": {
"details": [{
"comment": "Veggies is listed first.",
"appIDs": [ "0123456789.com.example.veggies" ],
"patterns": [
{ "/": "/nom-nom/*" }
]
},
{
"comment": "Fruits is listed second, and is only consulted if the first section didn't match anything on the user's device.",
"appIDs": [ "0123456789.com.example.fruits" ],
"patterns": [
{ "/": "/nom-nom/*" },
{ "/": "/fruits-but-not-veggies/*" }
]
}]
}
}


Of course, your app IDs and pattern dictionaries are specific to your applications. And they can differ between applications—in this example, note that "Fruits" also matches a separate pattern that "Veggies" doesn't match.

And what is the behavior if both appIds are listed in the appIds array of the same details entry?

Hi all, if you're running into this post looking for a way to open multiple apps from the same AASA, please refer to @Frameworks Engineer 's answer except using the key "components" instead of "patterns". Eg:

	"applinks": {
		"details": [{
			"comment": "Veggies is listed first.",
			"appIDs": [ "0123456789.com.example.veggies" ],
			"components": [
				{ "/": "/nom-nom/*" }
			]
		},
		{
			"comment": "Fruits is listed second, and is only consulted if the first section didn't match anything on the user's device.",
			"appIDs": [ "0123456789.com.example.fruits" ],
			"components": [
				{ "/": "/nom-nom/*" },
				{ "/": "/fruits-but-not-veggies/*" }
			]
		}]
	}
}

With this change to "components" instead of "patterns", you should be able to match to certain components of a link even for 2 separate apps

Universal Links to multiple apps
 
 
Q