Created
January 8, 2019 02:58
-
-
Save rdelrosario/93c406946918fc2c4bc99504221ea5dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
[assembly: XamlCompilation(XamlCompilationOptions.Compile)] | |
namespace AppLinksSample | |
{ | |
public partial class App : Application | |
{ | |
public App() | |
{ | |
InitializeComponent(); | |
MainPage = new MainPage(); | |
} | |
protected override void OnAppLinkRequestReceived(Uri uri) | |
{ | |
if (uri.Host.EndsWith("xamboy.com", StringComparison.OrdinalIgnoreCase)) | |
{ | |
if (uri.Segments != null && uri.Segments.Length == 3) | |
{ | |
var action = uri.Segments[1].Replace("/", ""); | |
var msg = uri.Segments[2]; | |
switch (action) | |
{ | |
case "hello": | |
if(!string.IsNullOrEmpty(msg)){ | |
Device.BeginInvokeOnMainThread(async() => | |
{ | |
await Current.MainPage.DisplayAlert("hello", msg.Replace("&", " "), "ok"); | |
}); | |
} | |
break; | |
default: | |
Xamarin.Forms.Device.OpenUri(uri); | |
break; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment