'How can I open Deeplink but not Open with Dialog in Xamarin Android
I am doing Deeplink in Xamarin. Everything works fine when I open the link like this:
private async void _viewmore_Tapped(object sender, EventArgs e)
{
string linkapp = "https://mydomain.me/ProductDetail/1";
await Browser.OpenAsync(linkapp, BrowserLaunchMode.SystemPreferred);
}
App.xaml.cs
protected override async void OnAppLinkRequestReceived(Uri uri)
{
if (uri.Host.ToLower() == "mydomain.me" && uri.Segments != null && uri.Segments.Length == 3)
{
string action = uri.Segments[1].Replace("/", "");
bool isActionParamsValid = int.TryParse(uri.Segments[2], out int productId);
if (action == "ProductDetail" && isActionParamsValid)
{
if (productId > 0)
{
var getProdID = await _apiService.LoadProductID(productId);
detailProduct = getProdID;
var detailContentPage = new ProductDetail(detailProduct);
detailContentPage.BindingContext = detailProduct;
await MainPage.Navigation.PushAsync(detailContentPage);
}
else
{
// it can be security attack => navigate to home page or login page.
App.Current.MainPage = new NavigationPage(new MainView(0));
}
}
}
base.OnAppLinkRequestReceived(uri);
}
MainActivity.cs
//Invite App Link
[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "https",
DataHost = "mydomain.me",
DataPathPrefix = "/",
AutoVerify = true,
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "http",
DataHost = "mydomain.me",
AutoVerify = true,
DataPathPrefix = "/",
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
(For Android) Create a Digital Assets file named assetlinks.json
[
{
"relation":[
"delegate_permission/common.handle_all_urls"
],
"target":{
"namespace":"android_app",
"package_name":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"sha256_cert_fingerprints":[
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
]
}
}
]
I uploaded the link: https://mydomain.me/.well-known/assetlinks.json -> It's ok
When I execute: _viewmore_Tapped. It opens again Open with:
How can it not show the Open with dialog box, I want it to be able to automatically enter My App..
I know that the option: Always can be clicked, however I don't want that. Please note that when I select Open with My App it opens fine.
I've searched on google a lot, but I still haven't found a solution for it. Hoping for any help from everyone. Thank you
Update
Testing App-Links: https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site= https://mydomain.me:&relation=delegate_permission/common.handle_all_urls. And I found it to be fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


