I have had universal links setup on Android and working fine for some time. This year I began to do the IOS app and I followed the steps:
- Deploy Apple site association file and confirmed as working with the testing tool.
- Enabled associated links in my developer profile
- Added associated domain to signing and capabilities in XCode
The link just opens Safari every time instead of launching the app. I have tried everything I could find on every thread, most of which are out of date.
I’m running the latest packages of Ionic, Capacitor, Capacitor IOS etc. I can see that appUrlOpen isn’t firing but I believe that’s just a symptom of universal links not being properly registered in the XCode build since it’s my oauth POST request redirect that isn’t being captured.
Does anyone have a simple explanation for why this might not work ?
For anyone else who has trouble with this , here’s a checklist to perform if you have already done the above and the universal link still doesn’t work:
- Ensure that your entitlements file (App.entitlements) has been included in the build:
If there is no checkbox ticked under Target Membership go to step 2.
- On your target app, go to build phases and manually add the entitlements file there.
- Try and launch the app from the link
xcrun simctl openurl booted https://yoururl.com
Note: the link will not work without a valid HTTPS URL and it will also not work with any port number after it. I found this out the hard way!
I hope that this helps someone in the future.
Re: oauth redirects, the best way to do this is to use a custom URL scheme and redirect using capacitor’s inAppbrowser. Otherwise you will keep getting redirected to Safari instead of back to the app with the oauth code.
Thanks @willedwards78. I was stuck but thanks to your advice I do some progress.
No worries @DidoMarchet, yes this can be a very problematic thing to configure. I had endless days of pain over it which is why I wanted to put something out there to clarify it. Happy it helped someone already !
Thank you so much! I never would’ve realized that I was missing that. What would cause that box to become unchecked?
Hey no worries, it was very problematic for me so I wanted to share it, save some other people the time. I think it’s great that Apple have this UI which represents the XML values as environment variables in XCode but I have no idea how mine became unchecked or rather why it wasn’t in the config that Capacitor generated. I’ve recently completed a release and there are also other things needed in the config files which aren’t autogenerated by capacitor so I just had to look them up and add them.