iOS Universal Links are not opening in-app
Asked Answered
V

46

152

So I followed this tutorial exactly and use the same values as the ones provided: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9

The Apple Association file is also ready in the link directory:
WEB_PAGE:PORT_NUMBER/apple-app-site-association

Everything seems to be set up on this side.

I've added the entitlements, updated the provisioning profile, and everything's set up.

When I run the app on my device, and open the link http://WEB_PAGE:PORT_NUMBER, this always opens Safari.

I even have breakpoints in the following method:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler

But zilch.

Has anyone perfected this? Is there something I'm missing?

Vibration answered 23/9, 2015 at 23:45 Comment(1)
checkout here to make sure you not miss any step #35610167Pless
G
223

There are a few possible issues.

  1. Try pasting your domain into this link validator and make sure there are no issues: https://limitless-sierra-4673.herokuapp.com/ (credit to ShortStuffSushi -- see repo)

  2. iOS logs an error message in the system logs if you don't have TLS set up properly on the domain specified in your entitlements. It's buried in the OS logs, not application logs. The error message will look like Sep 21 14:27:01 Derricks-iPhone swcd[2044] <Notice>: 2015-09-21 02:27:01.878907 PM [SWC] ### Rejecting URL 'https://examplecustomdomain.com/apple-app-site-association' for auth method 'NSURLAuthenticationMethodServerTrust': -6754/0xFFFFE59E kAuthenticationErr. Error message pulled from here, quick (incomplete) instructions on using CloudFlare for TLS here.

  3. In my personal testing, clicking/typing in a link in Safari has never once opened the app directly. Clicking from other apps (iMessage, Mail, Slack, etc.) has worked. Others have reported that clicking links in Google search results have opened the app directly.

  4. Note that if a Universal Link succeeds in opening your app and then you click through to Safari (by tapping your site in the top right corner of the nav bar in app), then iOS stops opening the app when you visit that URL. Then in Safari, you can pull down to reveal a banner at the top of the page with "Open". I wasted a lot of time on this. Note that clicking through to the site => disabling UL seems path specific, based on the paths you specify in the apple-app-site-assocation file. So if you have separate routes, yoursite.com/a/* and yoursite.com/b/*, if you click yoursite.com/a/* and it opens your app directly, you then have the option in the top right corner of the app to click through to yoursite.com/a/*. If you do that, subsequent visits to yoursite.com/a/* will open in browser, not app. However, yoursite.com/b/* should be unaffected and still open your app directly.

Let me know if you discover what the issue is. I'm personally very curious about how Universal Links work and what edge cases exist.

Gardal answered 24/9, 2015 at 0:54 Comment(35)
This is an awesome answer. I will need to dig into the error. Thanks for the link validation URL.Vibration
I've gotten universal links working for iMessage and Mail, but when trying to open from Slack or Twitter, the links open is Safari. (Slack a SafariViewController and Twitter a web view). Twitter's universal links seem to be fine in Slack, iMessage, and Mail, while another app called Quip has them work in iMessage and Mail, but not Slack (same issue as us). Any ideas?Tandie
I should go back and test extensively between apps/browsers using my test app. I'm not sure why Twitter would work in Slack but for your app it wouldn't. Related, one app I've advised claims that they have UL working and I can see that their apple-app-site-association file is correct, but I can't get links to open their app directly even in Mail and iMessage. Universal Links still seem finicky.Gardal
Hmm very strange, they do seem quite finicky. Thanks for your input!Tandie
Same thing. So weird. Sometimes it opens the app directly, sometime it opens the webView. I wish they made the documentation clear. Operation of this feature is erraticVibration
Does anyone know what the failed: -6756/0xFFFFE59C kTypeErr is for? The file doesn't have an extension and using rails to send_file 'path/apple-app-site-association', type: "application/pkcs7-mime". I can't find anything about this errorCatholicon
I've seen this error when the apple-app-site-association file is not served over HTTPSGardal
"Clicking from other apps (iMessage, Mail, Slack, etc.) has worked" - it also works when clicking from google search results inside safary (if it links to your page)Contamination
Slack recently switched from using SFSafariViewController (which did not work with Universal Links) to opening Safari / respecting Universal Links. Seems like their experiment with SFSafariViewController was short livedGardal
@Martin I just moved the info to the original post -- good ideaGardal
Regarding 1), it is no longer required that you sign your apple-app-site-association file if you are serving it over https.Lowrance
If I'm looking for the error in the syslogs, would I typically find that it /var/log/syslog on Debian/Ubuntu?Lowrance
@Gardal "So if you have separate routes, yoursite.com/a/* and yoursite.com/b/*, if you click yoursite.com/a/* and it opens your app directly, you then have the option in the top right corner of the app to click through to yoursite.com/a/*. If you do that, subsequent visits to yoursite.com/a/* will open in browser, not app. However, yoursite.com/b/* should be unaffected and still open your app directly" are you sure about it. From what I tested, that does not seem to happen. Irrespective of the PATH, any URL from that domain seems to take to the web and not the app.Fondea
@Gardal - Regarding Your point 3 : "In my personal testing, clicking/typing in a link in Safari has never once opened the app directly.", Please check my answer. I had the same issue. But I figured out that UL doesn't work properly from the same domain. I checked with multiple iOS 9 devices. Some older devices were able to launch the app from the same domain. But some devices never launched the app on tapping the link, only "Open IN [Your app]" context menu item that shows up on long tapping the link would work in safari when the domain is same.Disproof
The above link fails to validate your ipa if you build and drag it to itunes and then crate an ipa out of it. You should archive your build properly and it would work.Calvano
Restarting your iOS Device might help as well. I triple checked all settings and the configuration and I was absolutely sure that everything is correct but it still wouldn't work. Then I tried with another device and it worked perfectly. I then deleted the app from the original device, restarted the device and reinstalled the app, then it just worked...Aesir
How to get back in app instead of safari if someone accidentally pressed website link on right corner of app ?Copperhead
I did not get Open in App banner anywhere. After long search, here is a solution: Type any link for your site in Notes app (which is a universal link). Now Click Done. Once it becomes a link, long click on it and select "Open in AppNAME-HERE" !Stutz
How to fix issue 4 in your answer by the programmer, not user? Could I disable the top right safari button when universal link open my app?Chee
This was not working for me when running on the iOS Simulator, but worked great when running on an actual device.Pointer
thanks for wasting that time and finding out what the issue was :) pulling down revealed the "open in the ... app" banner.Tangled
@Gardal Thanks for post. Beside, I still having same problem. Issue is it's almost overtime redirecting to Safari. I'm using Firebase service and creating common link for Android & iOS. For Android same link worked so perfect. Any suggestion on issue !!Lenora
My app is opening when clicked on UL, but continueuseractivity delegate is never called, any one help me please?Angst
the only thing that worked for me is 'open in safari', i wasted hours on thisChemaram
@Gardal let's say your app has two views (A & B). Is it possible to open view A if you click on yoursite.com/a/* and open view B if you click on yoursite.com/b/*?Levina
i have problem with :// chars url remove special charsPsychotherapy
I had the same problem and the device reboot solved it. Thanks!Canaigre
Did anyone made it worked perfectly ? Question 1) We put the aasa file under .well-known directory. It accessible with domain/apple-app-site-association or domain.com/.well-known/apple-app-site-association . Which one is right ? Question 2) Does SSL certificate is must ? We are working on dev server now. From email app , i clicked the url i put on associated domain. It is not working. My aasa file : { "applinks": { "apps": [], "details": [ { "appID": "Prefix.appbundleID", "paths": ["*", "/"] } ] } }Unintelligent
@Copperhead Force press on the link and click "Open in [#APPNAME]"Vida
@DFedor raises a good point, "It wasn't necessary to sign the apple-app-site-association file: it is just plain text, and it works, as long as it's served over HTTPS." The link used to 'validate' my file in #1 said, "Your file must be served with content type "application/pkcs7-mime." But, I was sure my file was served properly because aside from a domain name change, the settings and everything was the same as I had used successfully prior. Without any changes, I merely restarted my phone and the link opened up in app.Vida
Your links are 404'ed @st.derrick, possible to give an update?Delicate
Not working when i hit url from the browser and it work when i click url from messenger or whatsapp.Hecklau
For me, the problem was that the iOS project had more than one .entitlement file, and the useful one wasn't edited when I changed the file on xCode. Search for *.entitlement in your project and make sure you include the domains there as well.Matildematin
Thanks for your explanation, I made a mistake and tried to test it using safari, but after using Note instead of safari, it workedKenneth
Anyone discovered how to reset the behaviour? To open the link in app instead of Safari if I pressed Safari link?Yachtsman
K
93

There are a lot of ways this can go wrong. Two points caused me trouble:

  • In Xcode, when you add the Associated Domains entitlement, each entry needs to start with applinks: and then your domain name. E.g. applinks:www.apple.com.

  • Though Xcode created an entitlements file for me, it did not include in my build: I had to click that box manually.

And yes, after doing that, it wasn't necessary to sign the apple-app-site-association file: it is just plain text, and it works, as long as it's served over HTTPS. (You'll still need to sign it if you're supporting iOS 8, though.)

Kabul answered 23/10, 2015 at 14:35 Comment(14)
I also had to delete the app completely from the test device and then build and run again before it finally worked.Josuejosy
you save my day, this was my issue, though XCode created an entitlements file for me, it did not include in my build: I had to click that box manually.Arsonist
Same problem here, I had to add the entitlements file to the build AND to delete the app on the deviceDelarosa
Including the entitlements file in the build fixed the issue for me as well. It's worth noting that in Xcode 8 the target membership checkboxes in the File Inspector are actually disabled. I had to go to the build settings and add the entitlements file to the Copy Resources phase.Outplay
@cham: can you guys elaborate on "though XCode created an entitlements file for me, it did not include in my build: I had to click that box manually."Terminal
Could it be a problem, that my application communicates with website via http NOT https ?Faustina
as @Arsonist asked about "though XCode created an entitlements file for me, it did not include in my build: I had to click that box manually." which box had to be clicked. Where?Gibeon
@AwaisFayyaz Go to Build Phases > Copy Bundle Resources. Click the plus sign then add your entitlement file.Mudguard
Thanks! My problem is the entitlements is not copied.Pani
I had a complete blindness for the fact that Xcode by default uses "webcredentials:" for associated domains and not "applinks:". This was the first answer that made me recheck what I had in my entitlements.Nicolanicolai
applinks: prefix is what solved it for me. Adding my prefix, my Associated Domains Capabilities entry looks like this: applinks:mysubdomain.mydomain.comRhodic
Not working when i hit url from the browser and it work when i click url from messenger or whatsapp. Please help meHecklau
I really doubt that copying entitlements in your resources is going to change anything. It's a compile time thing that Xcode looks and uses to sign your app at so it shouldn't be part of the of the bundle at all. Puzzled by the reports here that it fixes or changes anythingTully
adding the applinks: and removing the protocole in xcode Associated Domains fixed the issue for mePassmore
M
80

To help debugging this issue, search for "swcd" in your device's console output when installing your app to see if registering your universal link worked or failed.

  1. Use an actual device, not the simulator.
  2. Delete the app from you device.
  3. Connect the device to your computer, and view the device's console output in xcode. (window -> devices -> [your device] -> open console). Keep this window open.
  4. Install your app and let it launch.
  5. Filter the console output to "swcd". If it's sucessful you will see something like the folowing screenshot. If it fails you'll see something else. If you don't see anything then you messed something fundamental like adding the Associated Domains entitlement.

Applink added successfully

Muchness answered 2/11, 2016 at 14:9 Comment(7)
Excellent tip! I was adding https:// to the applinks: entitlement and also specifying the full path I wanted to listen to which were both mistakes. I was specifying example.com/path* where I should only be specifying my domain.com and the AASA file at example.com then specifies the path against my app's bundle idAfrikaans
Can I wire you cash bonus?? I spent 2 days going through every step of this freaking universal link setup, nothing was helping until I tried your approach. I got really unfortunate to host my association file on a firebase's root folder for my domain, and it turned out that Apple queries .well-known/ subdirectory first, and firebase appear to respond to it with their own (!) correct association file that has no app linked. Goshhh how am I supposed to find this out, Apple?Kukri
Ahhh great hint! I didn't know about this device console, just looking at the Xcode console output. My trouble was that 2 out of 3 deeplink domains DID work, but not that last one. And there in the console I saw that for my last domain I had misspelled it with "appllinks:<domain>" (2 L's) Oh man… anyway, thanks again for a great way of checking if Universal Links are actually registered! (I found the console logs also Removing of the links when uninstalling the app :+1 )Eng
is it supposed to be that verbose by default? Because I don't get such detailed log.. does this mean that the operation is not successful?Impi
there is no swcd filtering i still see lot of not related rowsLeifleifer
How did you know what swcd is? Out of my curiosity.Ruwenzori
@EvgenyKarkan honestly it's been so long I don't remember. I certainly didn't already know about swcd before I started trying to figure this out. I must have stumbled upon it, possibly on this exact SO question, and figured out a process to make it easy to filter since I needed to manually do it many times.Muchness
D
42

There is apparently an error in the documentation for making the association file for Universal Links.

Where it says:

The value of the appID key is the app’s team ID and the bundle ID

it should say

The value of the appID key is the app’s Prefix and the bundle ID

For most apps, it seems that the Team ID and app prefixes are the same, but if your app has been in the store for many years, these values can be different.

To find this value, open the Member Center on https://developer.apple.com and look at "Certificates, Identifiers & Profiles", click "Identifiers", then "App IDs" in the table under "Identifiers". Find your app, and use the Prefix value and Bundle ID there to create your AppID for the association file.

Durian answered 5/2, 2016 at 15:17 Comment(1)
The problem with this solution is that if you are testing locally you can't use itBarbican
A
30

St.derrick's Answer is informative.

But to enable universal links again to open in app instead of safari we need to do the following thing.

  • Long press on Universal link in Mail or iMessage, then you will see options whether to open in safari or in App.
Annmarieannnora answered 27/10, 2015 at 6:46 Comment(3)
There is no option of app , only copy, open, add to reading list etcCopperhead
Almost went crazy debugging this problem, but THIS was the solution or me. Maybe if it's not set up correctly and Mail app opens the link in safari it always opens in safari? no idea, but i once did the long press -> open in 'myapp' ... and now the links open correctly!Anatomical
Thanks a lot for this solution. I was stuck up in this for almost a day. You saved my day.Spiritualty
R
30

To validate apple-app-site-association on the server side, you can use Apple's official validator.

https://search.developer.apple.com/appsearch-validation-tool/

Raffin answered 18/12, 2015 at 20:53 Comment(2)
No longer working as of 2023. 503 errorWilmawilmar
You can use branch.io validator: branch.io/resources/aasa-validatorShulamith
I
24

It's also super important to increment the project version or build number after integrating universal links. Even if you delete/reinstall, iOS won't pickup the links unless you bump the version.

Iloilo answered 27/5, 2016 at 20:8 Comment(1)
This! The bundle version was totally what was causing my testing to fail, because I would go through all the above advice and my links would still launch Safari as iOS is using the cached result from the previous version of apple-app-site-association which had the wrong appId prefixPhlegm
M
22

I realized that be problem for me was that links to the root directory a (eg. http://example.com/) did not open my app but if I added a path (eg. http://example.com/mypath) it worked. Adding "/" to the paths list sovled it:

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

As answered by slutsker in this Apple Developer Forums thread.

Matronage answered 14/10, 2015 at 7:36 Comment(0)
R
21

For anyone who needs to easily test opening (Universal) Links, you can also open the link in your Simulator from the terminal with this command:

xcrun simctl openurl booted yourapp_or_http://yourlink

for example:

xcrun simctl openurl booted https://www.google.com

Rozanneroze answered 20/12, 2017 at 7:12 Comment(2)
I haven't got this to work, it always just opens up Safari. They do work when I run on an actual device though. Any ideas would be appreciated as it's a bit more painful debugging/developing without the simulator.Goodwife
Worked for me. There should be a "Open with <your app>" banner shown on top of the safari page. If not, pull down to refresh and it should show up.Octennial
D
17

Quick steps to check whether you have implemented Universal Link correctly.

  • Tap and hold on the link that you expect to launch the app. You should see a "Open in [your app name]" in the Context Menu.

  • Open Notes app, type the link you expect to open the app. Tap Done. The link will turn yellow and tapping on the link should open your app, and not Safari.

  • If the link http://yourDomain.com is not launching the app, try http://yourDomain.com/yourFolder/

  • In Safari, If the Context Menu shows "Open in [your app name]" in safari, but tapping the link opens the link in safari itself instead of launching the app,

    a. Try pulling down on the safari page that opened when the link was clicked like the way you 'pull to refresh'. A banner should appear that can open your app. Tap the banner to open the app, close the app by pressing home button, get back to safari and try launching the app by tapping the link again. This time on, the app should get launched because tapping the banner should have saved the preference to open the link in app.

    b. If the app still don't get launched after the step a., try mailing the link to a webmail such as gmail and open the webmail site in safari and try clicking the link. If this works, you may have been trying to launch the app from the same domain as the link. From what I have seen, launching the app from the same domain mostly fails. Probably safari wont care to check whether the destination url is a universal link, when the link is into the same domain that user is on. So try to launch the app from another domain.

Disproof answered 5/11, 2015 at 20:52 Comment(1)
That was it, have being dealing with this issue for hours, LAUNCHING THE APP FROM THE SAME DOMAIN MOSTLY FAILS. Thanks :)Cryptography
S
15
  • Universal Links will not work if you paste the link into the browser URL field.

  • Universal Links work with a user driven <a href="..."> element click across domains. Example: if there is a Universal Link on google.com pointing to bnc.lt, it will open the app.

  • Universal Links will not work with a user driven <a href="..."> element click on the same domain. Example: if there is a Universal Link on google.com pointing to a different Universal Link on google.com, it will not open the app.

  • Universal Links cannot be triggered via Javascript (in window.onload or via a .click() call on an <a> element), unless it is part of a user action.

source: https://dev.branch.io/getting-started/universal-app-links/support/ios/#appsbrowsers-that-support-universal-links

The 3rd bullet cost me about a day to figure out.

Strohl answered 7/10, 2016 at 22:12 Comment(3)
3rd bullet, same here: wasted many hours figuring that out. Apple has even a nice very stupid explanation for it: "iOS respects the user’s most likely intent and opens the link in Safari" see yourself here.Disfigurement
3rd bullet TOP !Alexandrina
3rd bullet should be the correct answer! I just spent 4 hours on this. Thank youGuillotine
M
8

I have found 2 useful tools that you can use to debug issues with Universal Links:

  1. On your phone, open the Settings app, select the Developer menu -> enable Association Domain Development and select Diagnostics. Insert the url that you have added to your entitlements file, and it will be validated: enter image description here

  2. The second one is mentioned in Apple's TN3155: Debugging universal links article. I recommend you read the full article, but especially the Host and verify your AASA chapter.

The mention using swcutil to verify your AASA files:

You can use these commands in Terminal by:

Running sudo swcutil dl -d <domain> to check that the AASA JSON can be downloaded successfully.

Running sudo swcutil verify -d <domain> -j <path-to-JSON> [-u <URL>] to check the contents of a downloaded .json AASA file. Verify that your domains match with -d and your URL path pattern matches with the JSON with -u. If both are successful, you will get a confirmation message.

For an app containing applinks:example.com and the AASA shown above, here is an example of using swcutil verify where “s” is the service, “a” is the App ID, and “d” is the domain:

% sudo swcutil verify -d example.com -j ./example.json -u https://example.com/test
{ s = applinks, a = ABCD123.com.example.app, d = example.com }:
Pattern "https://example.com/test" matched.

Since the pattern /test is included in the AASA, the JSON has successfully pattern matched and is verified. For the path /path/1, since it is set to be excluded in the AASA, you would see a message confirming the exclusion:

Pattern "https://example.com/path/1" blocked match.
Markland answered 16/10, 2023 at 20:0 Comment(0)
V
7

Incase people here are looking for other solutions, we put together a whole step-by-step on debugging Universal Links as we've seen a lot of issues pop up, causing a LOT of headaches.

Check it out:

Universal Links Debugging Guide

Debugging Guide preview

If you're just looking to set up Universal Links fresh, this guide is really helpful:

iOS Deep Linking Setup Guide

Hope they're helpful!

Vinyl answered 22/5, 2016 at 23:54 Comment(2)
Very helpful, thanks! Worked for me when running on an actual device, but not the iOS Simulator.Pointer
Links no longer valid. The image is the only thing helpful now.Scourings
M
6

Just thought I would add some things I discovered in case more people encounter the same issues as me in the future. These are mostly related to authentication errors.

Even though apple doesn't explicitly state it, the apple-app-site-association file must be served over https, even if signed. The certificate used for https must also be trusted by apple. So while a certificate added to the device in Settings -> General -> Profiles will allow https in safari, it will not allow universal links to work.

In the device logs, on an authentication error between the device and the server, there will be a value printed like "TrustResultValue" : 4. A TrustResultValue of 5 means the certificate is for the wrong domain (Eg. test.com served from www.test.com). A TrustResultValue of 4 means the certificate is not trusted for this use.

There may be some helpful steps for debugging here. The "Testing access to apple-app-site-association" section is a step by step guide for how to make sure the device is getting the apple-app-site-association file. The steps boil down to:

  1. Uninstall the app. This is necessary because the file is downloaded on install.

  2. Stop the server from properly serving apple-app-site-association.

  3. In xcode, open Window -> Devices and then select your device.

  4. Open the device logs by clicking the triangle at the bottom of the window.

  5. Clear the logs by clicking the trashcan to clear any previous logs that might be related.

  6. Reinstall the app with xcode by clicking the play button.

  7. After the app has launched, if the device is correctly requesting the file then the device logs should contain an error that can be found by searching for "apple-app-site-association".

If the apple-app-site-association file is properly served (step 2 is left out) then there should be no error. An authentication error may instead be displayed if that is the problem.

Miscalculate answered 5/7, 2016 at 15:21 Comment(1)
I was doing SSL spoofing using Charles Proxy and this was resulting in a trust value of 4. When I turned off the proxy, it succeeded.Quadrisect
O
6

The most common cause is when user tap on the top right, thus telling iOS to NOT open the app (in this case Uber) in the future.

To fix, pull down to reveal the smart banner and tap on OPEN:

Pull down in Safari, and OPEN again

This will subsequently "remember" to open the app.

Olenta answered 26/9, 2016 at 3:16 Comment(0)
M
6

We've added apple-app-site-association file to this location:

https://example.com/apple-app-site-association

On iOS 9 it worked fine, but on iOS 10 it didn't work.

It appeared that problem was with .well-known path:

https://example.com/.well-known/apple-app-site-association

Because of https://example.com/.well-known/apple-app-site-association path redirected to https://example.com

<Notice>: Allowing redirect 'https://example.com/.well-known/apple-app-site-association' -> 'https://example.com/'
<Notice>: ### Rejecting AASA file size 154466 for URL https://example.com/.well-known/apple-app-site-association

In my opinion if somehow .well-known path doesn't work correctly it breaks universal links.

Magruder answered 5/10, 2016 at 16:16 Comment(3)
The manual clearly says that "The file needs to be accessible via HTTPS—without any redirects".Crusade
The manual also clearly says that "For apps that run in iOS 9.3.1 and later, the uncompressed size of the apple-app-site-association file must be no greater than 128 KB, regardless of whether the file is signed." This file is 154 KB.Playhouse
On iOS11 your server should explicitly return 404 status for: example.com/.well-known/apple-app-site-association then swcd uses fallback to root: example.com/apple-app-site-association. You can quickly check returned HTTP status with tools like PostmanChecani
W
6

For ios13, there is a new format - check out here https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app?language=objc

I updated my file to look like this:

 {
  "applinks": {
    "apps": [],
    "details": [
        {
          "appIDs": ["1234.app.company.appname"],
          "appID": "1234.app.company.appname",
          "components": [
            {
              "/": "/login"
            }
         ],
           "paths": [ "/login" ]
        }
    ]
  },
  "webcredentials": {
    "apps": ["1234.app.company.appname"]
  }
}
Whitening answered 27/2, 2020 at 14:59 Comment(2)
you'd need to add "exclude": true to components object in order to comment be trueLithology
@SurjeetRajput I have updated my answer, I copied the file from one of my production projects. This is working for me.Whitening
B
6

Sometimes I find that everything is fine with the association file but iOS decides to always open the universal link in Safari. To test if the app recognises the app link I add the URL to Notes or a Calendar entry and then long press it so the contextual menu appears. If it says "Open in {YOUR APP}" then the link is working but iOS is deciding to open it in Safari. Tapping "Open in {YOUR APP}" will tell iOS to open valid universal links via your app from then on.

Buran answered 14/7, 2021 at 23:29 Comment(0)
C
5

After spending a day trying to get this to work, Restarting my phone solved the problem.

Uninstalling/Reinstalling the app didn't work either.

Christian answered 12/11, 2019 at 23:58 Comment(1)
I really can't believe in iOS 15 such bugs with universal links are still possible - but yes, thanks man you saved my day!Diallage
G
4

I've managed to make it work, but it took quite some time and struggle. Note that unless you sign the apple-app-site-association file (signing is optional!) tapping on a link in Safari will not open your app (it has caused me a lot of headache).

Guardrail answered 29/10, 2015 at 12:47 Comment(2)
That is curious. Apple states in the docs that for pure Universal Links and the use in iOS9 you don't need signing. Only if you want to support iOS 8 Handoff / Shared Web Credentials should you need to sign. Interesting! I have the same problem, so I am going to try signing.Saveall
Signing is indeed optional. Tapping a link in Mobile Safari to trigger opening native iOS app is called "Web Browser–to–Native App Handoff", in which case, you will need to add activitycontinuation property to the apple-app-site-association json file. developer.apple.com/library/ios/documentation/UserExperience/…Raffin
P
4

After two days it turned out for me, that these kind of links (from branch)

applinks:xxxx.app.link

work only after Archiving (also Ad-hoc) the application and install it to the phone.

Patellate answered 4/9, 2017 at 10:37 Comment(0)
H
3

Took me close to a day to figure this out. The issue I had was not downloading the updated provisioning profiles in XCode (I also restarted XCode after this).

(Preferences > Accounts > View Details > Download All)

Harpsichord answered 9/2, 2016 at 23:26 Comment(0)
P
3

You can test universal links in simulator

From the App Search Programming Guide: Support Universal Links

Pebble answered 18/2, 2016 at 23:21 Comment(4)
Has anyone gotten universal links to work in a simulator? I've tried countless times and it never works. It does work using a real device with the same flows though.Transpacific
I haven't been able to test this either. Trying to get Safari to trigger universal links in the simulator has been futile, despite the fact that it works properly on a physical device.Glockenspiel
I've not been able to get them to work in the simulator either. @AlbertBori did you get this working?Goodwife
I'm almost certain they do not work in simulator. I'm familiar with all the other pitfalls, and I can never get them to work in simulator ..Spoonerism
S
3

Hope this helps someone because this took me about two days to figure out.

We had to add www. to our associated-domains in our .entitlements file.

        <string>applinks:www.yourdomain.com</string>
        <string>activitycontinuation:www.yourdomain.com</string>

Because if we used yourdomain.com instead of www.yourdomain.com our servers did a redirect -> 304 and then didn't include the content-type: application/json for the apple-app-site-association file.

N.B. the universal links still work for yourdomain.com and www.yourdomain.com

Studio answered 19/6, 2019 at 5:23 Comment(0)
K
3

If you are hosting your apple-app-site-association on Firebase, make sure to put it in /.well-known/ subdirectory! It appears that Xcode queries that URL first, and if it succeeds, it makes no attempt to query the apple-app-site-association in the root directory. For some reason, firebase engineers made the hosted websites to automatically respond to /.well-known/apple-app-site-association with an empty (but correctly formed) association file that overrides your custom one, leaving you with no clue why nothing works!

Kukri answered 16/7, 2019 at 9:36 Comment(1)
Finally! Thanks a lot. Is it written in somewhere? Firebase should document in somewhere.Manatarms
B
3

In my case I needed to make the server serve the apple-app-site-association file using content type: application/pkcs7-mime. In nginx I did it using this approach:

location ~ /.well-known/apple-app-site-association {
         default_type application/pkcs7-mime;
 }

As other suggested I also had to make sure I:

Note that I never saw the "success" messages in the Console app as shown in screenshots by another user. In the console I kept getting Entry [...] needs its JSON updated because the app PI changed, but this was not an issue.

Also note that when trying to open the apple-app-site-association in the browser, the file gets downloaded instead of displayed, but this was not an issue in my case.

And as always, use a real device, re-install app whenever you change things, potentially also restart device and maybe increment app version number.

Buckshot answered 22/1, 2021 at 13:56 Comment(1)
I missed the TEAM_ID element, that part wasn't clear to me in the official docs where mentioning ABCDE12345.com.example.appRenner
D
3

In my case the encoding of the file was incorrect.

Make sure you encode the file using UTF-8 and that you specify it in the Content-Type header:

Content-Type: application/json; charset=utf-8

You can easily verify it by pasting your URL on this site:

Invalid encoding Valid encoding

Denumerable answered 11/12, 2022 at 0:45 Comment(1)
yyyyes after a tow days of round and round , i figure out the unicode is my problem , thanks davidPlacia
S
2

Go to developer.apple.com and edit one of your distribution profiles. In the editing page you can open a pop up for App IDs that will show a list of your app names and in () round brackets behind the app's name it reveals all your real App IDs. Some apps might have your team ID as prefix but some do not. Make sure to use exactly what you see in that pop up menu inside the () and put it into the apple-app-site-association details appID field. I had exactly this issue with an app and its universal links.

Sucre answered 17/3, 2016 at 13:41 Comment(0)
C
2

The issue for me turned out to be the apple-app-site-association file. According to Apple's documentation, only the applinks parameter is required. I added the activitycontinuation parameter and it worked.

{
  "activitycontinuation": {
    "apps": [
      "9JA89QQLNQ.com.apple.wwdc"
    ]
  },
  "applinks": {
    "apps": [],
    "details": [{
        "appID": "9JA89QQLNQ.com.apple.wwdc",
        "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*" ]
      }]
  }
}
Cord answered 19/5, 2016 at 17:44 Comment(1)
3 years later and we hit this exact issue. Adding activitycontinuation is what fixed it for us.Precipitin
A
2

Haven't really seen the exact same issue/solution combo that got it working for me so might as well add mine incase someone has the same problem!

For my app I am using a custom URL scheme (set in APP_TARGET > Info > URL Types) and set the URL scheme from here into the Firebase console to match but still wasn't working.

My problem was actually two problems:

Watch out if checking Automatically Manage Signing

If you are checking Xcode's "Automatically manage signing" setting like I was, since I was just trying to make a quick demo app, you will want to ensure that the TeamID that is used matches the one in your Firebase console. I originally went to my Apple Developer Account and copied the team ID from my Membership page, but later saw that the actual ID being used by Xcode was different. (You can find this in APP_TARGET > General > Signing > Signing Certificate. For me it looked like iPhone Developer: My Name (TEAM_ID)).

Prefix your TeamID to your Bundle Identifier in your URL Types

After I ensured these matched in my Firebase console and Xcode, my next problem was the identifier for my URL scheme. It's typical to use your bundle identifier here, but Firebase actually prefixes this with the Team ID you gave in your Firebase console, so I had to prefix it to the identifier in the URL types section in Xcode as well.

After these two fixes and re-downloading the GoogleService-Info.plist file I had no problem open up my dynamic links.

Antibiosis answered 9/12, 2016 at 3:51 Comment(0)
C
2

After two days of total desperation, I think I've finally fixed it. Here is my solution:

It seems that older apps use a different app prefix than newer apps. Newer apps only use the Team ID for this purpose. If the app prefix and the team ID are not identical, it seems that you need to specify the activity continuation field in the apple app site association file:

{
    "activitycontinuation": {
        "apps": [
            "YOUR_APP_PREFIX.de.company.app"
        ]
   },
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "YOUR_APP_PREFIX.de.company.app",
        "paths": ["/*"]
      }
    ]
  }
} 

Another thing I experienced during my hell ride was that deleting the app and restarting the device seems to be the only way to force refresh this file.

Cutie answered 14/11, 2018 at 9:59 Comment(1)
"For Apps created after 2011 your App ID Prefix is your Team ID. However, for apps created during 2011 or before, it is possible to have different App ID Prefixes."Hinds
P
2

For me, after implementing all the answers from above and testing that the AASA file was indeed being downloaded with mpoisot's answer, my issue was that in Xcode I added the associated domain as:

applinks:example.com

and in my notes app I was trying to use:

Https://example.com

because my AASA is not signed and I wanted to ensure I was serving it through HTTPS. So it worked when in my notes app I tried to use:

example.com

It works for me on a physical device, using iOS 12.1.2 with either a development build from Xcode or a distribution build from Testflight

Philbrick answered 21/12, 2018 at 22:39 Comment(0)
P
2

**One Simple thing need to check: **

Open Xcode & go to singing & capabilities section -

  1. Uncheck Automatically manage singing

  2. Create development certificate (If not created with same team id)

  3. Create development provisioning profile

NOTE : TEAM ID MUST SAME AS YOU MENTION in apple app site association file (aasa file)

simple uninstall previous app and run project again then open safari browser on simulator or device -> it will work...!

It help me find out solution because I run my project using automatically manage singing (checkbox is tick)

enter image description here

Park answered 6/10, 2022 at 11:23 Comment(0)
Q
1

For me, my error was our site is redirecting www.domain.com to domain.com, so all the www.domain.com/* will fail because of that. Hope that helps.

Quincey answered 16/8, 2016 at 18:20 Comment(0)
P
1

For future readers that find this page ...

I had a similar situation. However, in my situation, iOS10 was working AOK, and no matter what I did (bump build numbers, delete/reinstall, etc), iOS9 seemed to refuse to work.

I was coming to this from iOS10, and needed to support iOS9. At the time, the documentation here - https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html - clearly states that the file may be placed at the root of the web-server (e.g. /apple-app-site-association) or in the .well-known folder (e.g. /.well-known/apple-app-site-association). Because I'm also supporting Android, which also uses the .well-known folder for a similar file, I decided to put both in there.

For fresh installs on iOS10, it clearly request the root file, fails, then requests the .well-known file, and succeeds.

For iOS9, it clearly requested the root file, fails, and does nothing else.

Solution: if you support iOS9, put the file at /apple-app-site-association.

Prot answered 2/8, 2017 at 17:14 Comment(0)
K
1

I was able to test Universal Links in the iOS Simulator by using the Calendar app.

I just created an event and added the URL I wanted to test in the event's URL field. Then, when viewing the created event, you can simply tap on the URL link and your app should open.

Kanara answered 25/10, 2017 at 17:10 Comment(1)
This doesn't seem to work for me, I have tried everything to get them to work in the simulator to no avail. They work fine on the actual device, but that's not ideal for development/debug. I've tried long pressing the link and there is no "Open in app" option.Goodwife
M
1

In my case my error was to put query parameters in paths:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "TEAM_ID.BundleIdentifier",
                "paths": [ "/auth-ui/hub?target=confirm&*" ]
            }
        ]
    }
}

when I remove '?target=confirm&*' from paths, it start to working

Maxentia answered 17/9, 2018 at 16:8 Comment(0)
V
1

I did not see someone provide a solution for Flask.

This worked for me.

EDIT: After two down-votes, I'd like to clarify that I still use this exact solution months later. It does work, but there are other reasons why it might not work immediately for your app. This includes that you will have to delete the app and restart your phone several times even. Eventually, it links. I'm not sure why it is so difficult, but this solution does work. So keep trying, and if you have any issues, feel free to comment them so I can try to help.

If you are using Flask, put the "apple-app-site-association" in your static folder, and then add this to your application.py file.

@application.route('/apple-app-site-association', methods=['GET'])
def apple_app_site_association():
    return application.send_static_file('apple-app-site-association')
Vida answered 22/8, 2019 at 3:30 Comment(2)
Downvoter, please explain why you downvoted so that we can improve the answer if it is inaccurate.Vida
reinstall app - save my day(and laptop)Silkweed
L
1

The reason in my case was an invalid JSON.

It didn't use " but ” because I copied it from some article and the "expert" author of the article put it with the signs like that, and I copied it from him.

BTW, there is still not the information box on the target site anyway like "you can open it with the app" but if i click the link eg from Notes app the app is opened.

wrong:

{
    “applinks”: {
        “apps”: [],
        “details”: [
            {
                “appID”: “T5TQ36Q2SQ.com.reddit.production”,
                “paths”: [“*”],
            }
        ]
    }
}

good:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "T5TQ36Q2SQ.com.reddit.production",
                "paths": ["*"],
            }
        ]
    }
}
Leifleifer answered 15/9, 2020 at 11:5 Comment(2)
Can't understand what different between them?Hsu
maybe wrong quotes “Leifleifer
H
1

In my cas it was not woking because I had 2 items in

<plist version="1.0">
<dict>
    <key>aps-environment</key>
    <string>development</string>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:urlOne</string>
        <string>applinks:urlTwo</string>
    </array>
</dict>
</plist>

when I reduce array to only one item it start to work.

Hinds answered 9/12, 2020 at 14:10 Comment(0)
T
1

There is a new format for file - check this link: https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app?language=objc

I updated my file like this:

"applinks": {
        "apps": [],
        "details": [
            {
                "appID": "APP_ID_PREFIX.BUNDLE_ID",
                "paths": [
                    "*"
                ]
            }
        ]
    },
    "webcredentials": {
        "apps": [
            "APP_ID_PREFIX.BUNDLE_ID"
        ]
    }
}

Note: In simulator it`s not working but, on device working perfectly.

Trimaran answered 24/2, 2021 at 14:42 Comment(0)
V
1

To validate apple-app-site-association file you can use this tool:

https://branch.io/resources/aasa-validator/#resultsbox

If you using something like cloudflare, make sure you didn't block countries in security rules

there are some countries that you should not block in order for app links to word

If you still have the error, go to apple developer account to where you register your app identifier, uncheck Associated websites and recheck it and then click save, open your project at xcode and disable auto manage signing and re enable it and choose your developer team, make sure the Association Domains capsbility and confirm the app links:example.com

if the issue still exists, make sure the apple-app-site-association route/file don't have content-type and try again, and if still have the issue, try out application/json

every time you try, delete the app and try build with different build number, try on different devices/simualtor, restart your router, your devices, try look at the console app in your Mac, you also might want to try use manual signing, allow any kind of links in apple-app-site-association just to make debugging easier

also try to use this command to test the link instead of open it in safari:

xcrun simctl openurl booted https://example.com
Valeta answered 15/5, 2023 at 12:33 Comment(0)
O
0

In my case, the request for the AASA file at: https://example.com/apple-app-site-association

Was being redirected to: https://www.example.com/apple-app-site-association

The kicker is -- this works fine on iOS 11, but fails on iOS 9.3.5. Go figure.

Solution: the apple-app-site-association file MUST NOT be behind a 302 or 301 redirect for iOS 9. (To be fair, this is noted on the UL troubleshooting page.)

Osculation answered 26/9, 2018 at 17:51 Comment(0)
T
0

I'll also put my notes on troubleshooting.

Basically we have 2 parts, that should be linked together: 1) web site and 2) an iOS app.

  1. For the web site there was only one issue: MIME type for apple-app-site-association file was not application/json.

    Also API Validation Tool wasn't helping us, for test environments it was saying

Error no apps with domain entitlements The entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update.

but in the end web site was ok.

We checked web logs, saw GET request to apple-app-site-association file and decided to switch to iOS app.

  1. For dealing with iOS app setup it is good to have Console app running, with filtering for showing only swcd process, as was already mentioned in this thread.

In our case the issue was that we rely on wildcard URL, in the form: applinks:*.prod_site_name.com, thinking that * will cover all test environment prepending, like https://test_env.num4.prod_site_name.com, but this is not working. Console was showing:

Started request for domain '*.prod_site_name.com', URL 'https://prod_site_name.com/.well-known/apple-app-site-association'

So the fix in our case was to provide test-specific applinks for test target of the app, like: applinks:test_env.num4.prod_site_name.com

Tabbie answered 5/6, 2019 at 12:45 Comment(0)
N
0

I know there are already a lot of answers but you need to make sure that, in addition to the Developer Console (Apple's website), you also need to add the Associated Domains capability to the app via xCode. I had never done this process before and there isn't much documentation on it (including React Native's docs).

(Screen recording of the process below). https://i.stack.imgur.com/A7B1l.jpg

Neruda answered 1/9, 2022 at 22:41 Comment(0)
P
-2

for my case it was because I didn't enable the Association Domain Development in Developer menu in iOS Settings on the device. and it doesn't work on simulator

Pluckless answered 13/11, 2023 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.