0
votes

I have set up a simple Xamarin app to try and use Deep Linking. The Deep Linking works perfectly when I use the IOS simulator. But I can't seem to get it to work for Android while debugging using an Android device.

I've set up my MainActivity.cs like so

[IntentFilter(new[] { Intent.ActionView },
    Categories = new[] {
        Intent.ActionView,
        Intent.CategoryDefault,
        Intent.CategoryBrowsable
    },
    DataScheme = "photocapture",
    DataHost = "PhotoCapture",
    DataPathPrefix = "/photocapture/")
]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        AndroidAppLinks.Init(this);

        LoadApplication(new App());
    }
}

Then in my App.cs I have an override for OnAppLinkRequestReceived

protected override async void OnAppLinkRequestReceived(Uri uri)
{ .... }

On the Android device I've download a HTML file with the following href

<html>
 <head>
  <title>Product 12345</title>
 </head>
 <body>
  <a href="photocapture://PhotoCapture.Views.PhotoCapturePage?id=123">Deeplink</a>
 </body>
</html>

When I click this link on the Android device the app is not opening up and the OnAppLinkRequestReceived is not catching in the debugger.

Also if I search the app name of the android device it does show up. The problem is just when clicking deep link from an external source.

Am I missing a step or have I done something wrong?

1
Maybe you should refer this for more help. - Dishant
Did you want to open your app in a webview? - Lucas Zhang - MSFT

1 Answers

0
votes

The link I was using that worked in IOS:

photocapture://PhotoCapture.Views.PhotoCapturePage?id=123

Did not work on android. I had to change photocapture:// to http:// to get it to work. So the final link looked like:

http://PhotoCapture.Views.PhotoCapturePage?id=123