iOS Universal Links are not opening in-app
Solution 1
There are a few possible issues.
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)
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.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.
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/*
andyoursite.com/b/*
, if you clickyoursite.com/a/*
and it opens your app directly, you then have the option in the top right corner of the app to click through toyoursite.com/a/*
. If you do that, subsequent visits toyoursite.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. Good luck.
Solution 2
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.)
Solution 3
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.
- Use an actual device, not the simulator.
- Delete the app from you device.
- 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.
- Install your app and let it launch.
- 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.
Solution 4
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.
Solution 5
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/
Comments
-
Legolas almost 3 years
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?
-
Vineet Choudhary about 8 yearscheckout here to make sure you not miss any step stackoverflow.com/questions/35609667/…
-
-
Legolas over 8 yearsThis is an awesome answer. I will need to dig into the error. Thanks for the link validation URL.
-
Kazzin over 8 yearsI'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?
-
st.derrick over 8 yearsI 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.
-
Kazzin over 8 yearsHmm very strange, they do seem quite finicky. Thanks for your input!
-
Legolas over 8 yearsSame 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 erratic
-
LyricalPanda over 8 yearsDoes anyone know what the
failed: -6756/0xFFFFE59C kTypeErr
is for? The file doesn't have an extension and using rails tosend_file 'path/apple-app-site-association', type: "application/pkcs7-mime"
. I can't find anything about this error -
st.derrick over 8 yearsI've seen this error when the apple-app-site-association file is not served over HTTPS
-
IPv6 over 8 years"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)
-
st.derrick over 8 yearsSlack 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 lived
-
st.derrick over 8 years@Martin I just moved the info to the original post -- good idea
-
Jeremy Hicks over 8 yearsRegarding 1), it is no longer required that you sign your apple-app-site-association file if you are serving it over https.
-
Jeremy Hicks over 8 yearsIf I'm looking for the error in the syslogs, would I typically find that it /var/log/syslog on Debian/Ubuntu?
-
bhasker_kottapally over 8 years@st.derrick "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.
-
Nikhil Mathew over 8 years@st.derrick - 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.
-
wrtsprt over 8 yearsThat 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.
-
Ankit Srivastava over 8 yearsThe 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.
-
Devy over 8 yearsSigning 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 theapple-app-site-association
json file. developer.apple.com/library/ios/documentation/UserExperience/… -
Phil Andrews over 8 yearsI also had to delete the app completely from the test device and then build and run again before it finally worked.
-
cham over 8 yearsyou 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.
-
mathz over 8 yearsRestarting 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...
-
Ivo about 8 years+1, This helped me a lot. Spend half a day figuring out why it didn't work and this seemed to be the case for me
-
iEngineer about 8 yearsThere is no option of
app
, only copy, open, add to reading list etc -
iEngineer about 8 yearsHow to get back in app instead of safari if someone accidentally pressed website link on right corner of app ?
-
user361526 almost 8 yearsSame problem here, I had to add the entitlements file to the build AND to delete the app on the device
-
Tony almost 8 yearsHas 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.
-
Ben Flynn almost 8 yearsI 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.
-
Albert Bori almost 8 yearsI 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.
-
Herbert Poul almost 8 yearsAlmost 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!
-
kishorer747 almost 8 yearsI 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" !
-
Gon almost 8 yearsHow 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?
-
Josh Sklar over 7 yearsThis was not working for me when running on the iOS Simulator, but worked great when running on an actual device.
-
Josh Sklar over 7 yearsVery helpful, thanks! Worked for me when running on an actual device, but not the iOS Simulator.
-
Charles A. over 7 yearsIncluding 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.
-
zai chang over 7 yearsThis! 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 prefix -
eonil over 7 yearsThe manual clearly says that "The file needs to be accessible via HTTPS—without any redirects".
-
andrew over 7 yearsThanks a lot for this solution. I was stuck up in this for almost a day. You saved my day.
-
Joris Weimar over 7 yearsthanks for wasting that time and finding out what the issue was :) pulling down revealed the "open in the ... app" banner.
-
neiker over 7 yearsKyle, I think I love you! This answer save the day, thank you!
-
Roberto about 7 yearsThe 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.
-
CoDe about 7 years@st.derrick 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 !!
-
nurider about 7 yearsThis was the secret sauce for me! Thank you thank you thank you!
-
jox almost 7 years3rd 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.
-
Thang Pham almost 7 years@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."
-
Ti3t over 6 yearsyou saved my day, in deed my app was long time ago and app prefix is different from team ID.
-
Max Odnovolyk over 6 yearsOn 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 Postman
-
anitteb over 6 yearsCould it be a problem, that my application communicates with website via
http
NOThttps
? -
maledr53 over 6 yearsThat was it, have being dealing with this issue for hours, LAUNCHING THE APP FROM THE SAME DOMAIN MOSTLY FAILS. Thanks :)
-
BharathBob about 6 yearsMy app is opening when clicked on UL, but continueuseractivity delegate is never called, any one help me please?
-
Awais Fayyaz about 6 yearsas @cham 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?
-
Hanane about 6 yearsthe only thing that worked for me is 'open in safari', i wasted hours on this
-
kk-dev11 almost 6 years@st.derrick 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/*?
-
Ryan110 almost 6 yearsi have problem with :// chars url remove special chars
-
s.zainulabideen over 5 years@AwaisFayyaz Go to Build Phases > Copy Bundle Resources. Click the plus sign then add your entitlement file.
-
Egist Li over 5 yearsThanks! My problem is the entitlements is not copied.
-
chib over 5 yearsThis 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.
-
chib over 5 yearsI've not been able to get them to work in the simulator either. @AlbertBori did you get this working?
-
chib over 5 yearsI 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.
-
NYS over 5 yearsI had the same problem and the device reboot solved it. Thanks!
-
Numan Tariq over 5 yearsExcellent 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 id
-
dhin about 5 yearsthis is the only thing that works for me. thank you!
-
Jamshed Alam about 5 yearsDid 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": ["*", "/"] } ] } }
-
rob5408 about 5 yearsI 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.
-
readyornot almost 5 years3 years later and we hit this exact issue. Adding
activitycontinuation
is what fixed it for us. -
nalexn almost 5 yearsCan 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?
-
Berkay Turancı almost 5 yearsFinally! Thanks a lot. Is it written in somewhere? Firebase should document in somewhere.
-
Fattie almost 5 yearsI'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 ..
-
FranticRock almost 5 yearsapplinks: prefix is what solved it for me. Adding my prefix, my Associated Domains Capabilities entry looks like this: applinks:mysubdomain.mydomain.com
-
Joshua Wolff over 4 years@iEngineer Force press on the link and click "Open in [#APPNAME]"
-
Joshua Wolff over 4 years@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.
-
Joshua Wolff over 4 yearsDownvoter, please explain why you downvoted so that we can improve the answer if it is inaccurate.
-
vincenth over 4 yearsThis was the solution for me. Great advice.
-
CyberMew about 4 yearsYour links are 404'ed @st.derrick, possible to give an update?
-
Byteros about 4 years3rd bullet TOP !
-
Arno Teigseth about 4 yearsAhhh 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 )
-
Nicholas Allio about 4 yearsis 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?
-
skornos almost 4 yearsyou'd need to add
"exclude": true
tocomponents
object in order tocomment
be true -
luky over 3 yearsthere is no swcd filtering i still see lot of not related rows
-
Rotem over 3 years3rd bullet should be the correct answer! I just spent 4 hours on this. Thank you
-
Anita over 3 years@SurjeetRajput I have updated my answer, I copied the file from one of my production projects. This is working for me.
-
Jakub S. over 3 years"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."
-
Pramod Tapaniya over 3 yearsNot working when i hit url from the browser and it work when i click url from messenger or whatsapp.
-
Pramod Tapaniya over 3 yearsNot working when i hit url from the browser and it work when i click url from messenger or whatsapp. Please help me
-
App Dev Guy almost 3 yearsLinks no longer valid. The image is the only thing helpful now.
-
Evgeny Karkan almost 3 yearsHow did you know what
swcd
is? Out of my curiosity. -
mpoisot almost 3 years@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.
-
Huy Nguyen over 2 yearsreally helpful to me. thansk!
-
Starwave over 2 yearsWooooow, this is the diamond among the rubbles! Thank you!!
-
Dmitry Salnikov about 2 yearsI really can't believe in iOS 15 such bugs with universal links are still possible - but yes, thanks man you saved my day!
-
Huynh Inc almost 2 yearsCan't understand what different between them?
-
luky almost 2 yearsmaybe wrong quotes “