adinas
adinas

Reputation: 4550

Deep linking in .NET MAUI app on Android only partially works

I am trying to implement deep linking in my app. That is, when a user goes to my website, it should open the app.

I feel like I am missing something small to get this to finally work but I don't know what. Below my description I'll attach screenshots of everything I mention.

To test if it works, I've created a webpage with two links on it. One link links to the Application ID (which in my case is "il.co.lilo.journal_app_v2") so the link is: https://il.co.lilo.journal_app_v2/bubu/1. When clicking on it, the app opens and I handle the event in the MainActivity.cs file, in the OnCreate event. So that works (though when you go back to the browser it shows an ugly 'Site can't be reached' error).

The other link, links to my website "https://lilo.co.il/bubu/1". Clicking on this link simply goes to the website without opening the app and this is what I need help with.

I've created the assetlinks.json and it exists at https://lilo.co.il/.well-known/assetlinks.json

For testing I created an APK using the keystore file I used for the assetlinks.json file and installed on my phone.

My MainActivity.cs file has the following Intent Filters:

[IntentFilter(new[] { Android.Content.Intent.ActionView },
                      DataScheme = "http",
                      DataHost = "lilo.co.il",
                      DataPathPrefix = "/bubu",
                      AutoVerify = true,
                      Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
                      DataScheme = "https",
                      DataHost = "lilo.co.il",
                      DataPathPrefix = "/bubu",
                      AutoVerify = true,
                      Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
                      DataScheme = "http",
                      DataHost = "il.co.lilo.journal_app_v2",
                      DataPathPrefix = "/bubu",
                      AutoVerify = true,
                      Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
                      DataScheme = "https",
                      DataHost = "il.co.lilo.journal_app_v2",
                      DataPathPrefix = "/bubu",
                      AutoVerify = true,
                      Categories = new[] { Android.Content.Intent.ActionView, Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]

Intent Filters

The HTML for the page I created to test is:

<a href="https://il.co.lilo.journal_app_v2/bubu/1">https://il.co.lilo.journal_app_v2/bubu/1</a><br>
<a href="https://lilo.co.il/bubu/1">https://lilo.co.il/bubu/1</a><br>

When clicking on the top link (https://il.co.lilo.journal_app_v2/bubu/1) my app opens great but when I go back to the browser, I see this which is not good:

enter image description here

When I click the second link, as I said before, it simply goes to the website even though when I look at my apps "Supported web addresses" in the App Info:

enter image description here

I can see it shows my site URL:

enter image description here

Upvotes: 1

Views: 1546

Answers (1)

adinas
adinas

Reputation: 4550

Okay, So I finally got it to work.

The following steps are what I did to get it working (please correct me if there is an easier way)

  1. I created an app in the Google Play console and then created a bundle in VS and uploaded it (in other words you can't test deep linking without opening a Google development account).
  2. I then went to Grow -> Deep Links in the Google Play Console enter image description here
  3. It will give you details about the links defined in your manifest and will point out any issues. It will also check your assetlinks.json on the webiste and will tell you what your assetlinks.json needs to have if what you have is incorrect (in my case it had changes which I did)
  4. The link still did not work when testing in the emulator. It only worked after downloading the APK from the Google Play Console and installing on my phone:enter image description here and then enter image description here At this point, clicking on the link in a browser on my physical phone, opened my app correctly

Upvotes: 1

Related Questions