Ronanki Viswanadham
Ronanki Viswanadham

Reputation: 108

Deeplinking is not working in capacitor in Andriod & iOS mobile apps

We have followed the deep linking as per the capacitor Deeplinking documentation below and then we checked to click on the deep links and it doesn't take us to the mobile app and the URLs are opening in the browser.

https://capacitorjs.com/docs/guides/deep-links

  1. Created Site Association File and verified using Asset Links tool and app linked successfully to the domain.
  2. Also added the Intent Filters in the manifest file and gave the host as the website domain
  3. Followed everything as per documentation and tried these in the signed apk

Please help us if any other solutions - For deep linking using a capacitor

Upvotes: 1

Views: 1583

Answers (2)

Bash
Bash

Reputation: 1628

This is the top question that shows up in Google for Capacitor deep links issues on Android and iOS so I want to share some tips that may help in solving this problem.

Android

Once you deploy the .well-known/assetlinks.json file to your web host, make sure you use Google's Asset Links tool to test that the file is correctly accessible by clicking Test statement after entering the information. If it fails, you know there's an issue with that file. Also, one issue I ran into that is very hard to catch, make sure your SHA-256 string is all capitalized, otherwise it won't work.

Apple

Once you deploy the .well-known/apple-app-site-association file to your web host, use Branch.io's AASA validator tool and the yURL AASA validator to make sure your file is correct and reachable by Apple's CDN. I found Branch.io's tool is more accurate, but gives less helpful information than yURL.

Also you can query your domain in Apple's CDN with this url to find out if it's working: https://app-site-association.cdn-apple.com/a/v1/www.example.com. Replace www.example.com with your domain. In dev tools, you can open up the network request and find some of the Response Headers for more information including Apple-Failure-Details, Apple-Failure-Reason, Apple-From and Apple-Try-Direct. If the Cache-Control header says max-age=3600,public, it means you have to wait an hour until Apple will retry fetching your apple-app-site-association file. You can check the Age header to see how much time has passed since the last fetch.

Make sure this file isn't being served with a redirect. Check any caching your web host is doing if things aren't working. Lastly, I set the Content-Type header to application/json on mine through the _headers file as my web host is Cloudflare Pages.


Hope this helps anyone else who comes across this thread! I spent way too much time troubleshooting these issues.

Upvotes: 0

nalendro16
nalendro16

Reputation: 71

make sure your assetlinks SHA256 match exactly with signing key used for each build variant (debug build/firebase distribution/playstore) has different SHA256.

you can write an array and add some asstelinks so the each build like mentioned

And if you create production build on playstore, check your play console if there's error on deep link. My apps on android 12 & 13 only opened deeplink in browser, it just need to verify the site ownership.

Upvotes: 1

Related Questions