I'm currently developing an application with Xamarin Forms which I want to be able to open from a simple url.
On iOS part this works fine, but on Android nothing happens when I try to reach my url from chrome.
Here is my MainActivity:
[Activity(Label = "Lockers", Icon = "@drawable/logo", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "http",
DataHost = "random.com",
DataPathPrefix = "/test",
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable })]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
UserDialogs.Init(this);
global::Xamarin.Forms.Forms.Init(this, bundle);
App _app = new App();
LoadApplication(_app);
if (Intent.HasExtra("al_applink_data"))
{
var appLinkData = Intent.GetStringExtra("al_applink_data");
var alUrl = new Rivets.AppLinkUrl(Intent.Data.ToString(), appLinkData);
// InputQueryParameters will contain our product id
if (alUrl != null && alUrl.InputQueryParameters.ContainsKey("id"))
{
var id = alUrl.InputQueryParameters["id"];
NavigationPage nav = _app.MainPage as NavigationPage;
InputPage page = nav.Navigation.NavigationStack[0] as InputPage;
page.GenerateContentFromUri(id);
}
}
}
}
When I try to reach http://random.com/test url from chrome app this should normally propose to open the link either from the app or continue with chrome, but nothing is happening, it just goes to the website as if the intent-filter was ignored.
Do you guys know what I might be missing ?
Nevermind, everything is fine, I was just trying to type my url directly in the navigation bar of chrome.
To open the application from an url, it should be done by clicking on a link to make it work