16

After installing the app manually from xCode (with the device plugged to the MacBook) I can click mails with a link to the Web App and it opens it into the cordova app instead of the web app (as expected).

But when I download and install the app from AppStore or testFlight (with the exact same code base), Universal Links are ignored and the Web App is opened.

When I monitor Apache logs, and installing the app manually, I get :

XX.XX.XX.XX - - [29/Aug/2018:14:32:33 +0000] "GET /.well-known/apple-app-site-association HTTP/1.1" 200 730 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"

But while installing the app from testFlight or the AppStore, there is no request for that file.

Can someone help me to find even a clue to search for... How can I enabled UniversalLink for my production app?

[EDIT] from the john316's answer

I unzipped the IPA generated, openned the embedded.mobileprovision and I had:

<key>Entitlements</key>
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>XXXX.*</string>     
    </array>
    <key>get-task-allow</key>
    <true/>
    <key>application-identifier</key>
    <string>XXXX.my.domain.com</string>
    <key>com.apple.developer.associated-domains</key>
    <string>*</string>
    <key>com.apple.developer.team-identifier</key>
    <string>XXXX</string>
    <key>aps-environment</key>
    <string>development</string>
</dict>

Associated domains are enabled but shouldn't they have an array of string with all my applinks:domains?

Alexandre SIRKO
  • 816
  • 11
  • 22
  • For whatever hostname you listed for your Universal Link in Xcode, do you have an AASA file at `hostname/.well-know/apple-app-site-association`? Apple will need to fetch that file when it downloads the app from the App Store. You can ensure it's there by visiting `hostname/.well-know/apple-app-site-association` in your browser. More info: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html – Kyle H Aug 29 '18 at 16:16
  • I do have a AASA file accessible with the URL you gave. The [branch.io validator](https://branch.io/resources/aasa-validator/) also give me a all green validation. – Alexandre SIRKO Aug 30 '18 at 09:22
  • This will sound silly, but have you tried rebooting your phone? Sometimes the OS might not check for the .well-known file except under certain circumstances. Also, know that there is an open bug affecting Universal links. https://blog.branch.io/notice-inconsistent-universal-link-behavior-on-ios-11-2/ – Jeremy White Sep 04 '18 at 22:29
  • I tried to reboot, and different devices – Alexandre SIRKO Sep 06 '18 at 13:47
  • @KyleH I just noticed you wrote `.well-know`, i suppose thay you meant `.well-known` – Alexandre SIRKO Sep 06 '18 at 13:55
  • I encountered an issue a bit similar to this that was resolved by uninstalling the app from the device & having the fresh install then work. UL appear to be registered upon initial install, not updates. – CodeBender Sep 06 '18 at 19:22
  • @AlexandreSIRKO, check your distribution provision profile. Maybe you need to regenerate it – lobstah Sep 10 '18 at 17:08
  • Having the same issue? Any success in finding a solution? – Aravind Mariappan Dec 20 '18 at 11:34

4 Answers4

9

In my experience of observing differences like what you describe, in most cases, it has been due to the difference in the apps entitlements for dev & distribution profiles. Even though you may clearly state in your app project settings that you need certain capability (in this case "Associated Domains" checkbox), Xcode may not throw any error during signing process (when you export the app for distribution) if certain entitlements are missing in the provisioning profile.

They may be missing for 2 reasons - they may not have been added at the developer.apple.com portal for this profile, or Xcode didn't refresh the profile file from that portal. In the latter case, it helps to erase the old profile from your local disk to force Xcode to redownload it.

To verify that you actually have the com.apple.developer.associated-domains entitlement in your distribution file, you can unzip the IPA file and check for the com.apple.developer.associated-domains key in <key>Entitlements</key> section as specified here.

Another way to debug this is to look at the device logs in the Console (Xcode-> Window-> Devices&Simulators-> Open Console), when running the AppStore/TestFlight version of the app. You can find a log line that's output by the iOS when the link is followed correctly into the app for the dev version of the app, and compare it with the case when it fails. Usually iOS complains at that point about missing entitlements, in the logs.

john316
  • 306
  • 1
  • 8
  • Thank you for your detailed answer! I tried to open the **embedded.mobileprovision**. I found the `associated-domains` section but it's empty. Have you any ideas? – Alexandre SIRKO Sep 14 '18 at 14:57
  • Good question - I need to try it myself first. But you already have a build where it works (the dev one) - can you add the same lines from its *embedded.mobileprovision* file to your question as well? You should be able to find it somewhere here: ~/Library/Developer/Xcode/DerivedData/YourApp-hash/Build/Products/Debug-iphoneos/YourApp.app/embedded.mobileprovision – john316 Sep 14 '18 at 17:41
  • 3
    actually, looks like embedded.mobileprovision never mentions the list of the specific associated domains - all we care is that it mentions that entitlement is present. The list itself is mentioned inside of the executable itself (that's a binary file) - in this kind of form: `com.apple.developer.associated-domains applinks:get.myapp.org ` – john316 Sep 14 '18 at 20:44
3

Finally I was able to fix this issue:

Make sure that Entitlements-Release.plist includes the correct entitlements. In my case, only Entitlements-Debug.plist had the correct entitlements. Also when you export your app at the last step you usually should see a summary regarding included entitlements, make sure that com.apple.developer.associated-domains is listed with the appropriate applinks entry.

It should look similar to:

enter image description here

source: https://forums.developer.apple.com/message/334862

menelik
  • 51
  • 5
1

If You using Cordova/Ionic v3

There is bug...

Check these Step:

There Are Four process

1.app console

App ids -> select app id→ enabled Associated Domains -> Done Provisioning Profile -> Edit again

  1. On Xcode

AppName -> general <-> capability ->Associated Domains -> + ->

applinks:example.com

  1. On Your Server Upload apple-app-site-association file in root dir for http And .well-known folder for https

Ex - https://www.skyscanner.com/apple-app-site-association

Ex - https://www.skyscanner.com/.well-known/apple-app-site-association

Don’t append this file as json leave as text Ex -- of apple-app-site-association

4.(Important)

(cordova) project folder there are two files: Project -> plateform -> ios -> projectNameFolder ->

Entitlements-Debug.plist

Entitlements-Release.plist

When I add the value applinks:example.com to Capabilities->Associated domains->Domains, the Entitlements-Debug.plist got the lines:

 <key>com.apple.developer.associated-domains</key> <array>  
 <string>applinks:example.com</string> </array>

BUT the Entitlements-Release.plist did not change. What I did to solve the issue is to copy-paste the generated lines form the Entitlements-Debug.plist. After this, I did the exact same Archive and upload process as before and everything worked fine.

and use ionic-plugin-deeplinks to get params and Route your Deeplink process

.......Thanks Later First Build Your Project

Amit Pandey
  • 297
  • 2
  • 8
0

To check the applinks in the ipa file.

Go to ipa -> append .zip as extension. Unzip it. You will able to see payload. Now right click and check show package content.

In the package content, you will find archived-expanded-entitlements.xcent.
Drag and drop this file to text edit. You will see your app links that is configured in associated domain. This way you can find if you are using correct applinks or not.

Rajesh Maurya
  • 3,026
  • 4
  • 19
  • 37