2016-07-07 71 views
3

我试图使用https://developer.xamarin.com/api/member/Xamarin.Forms.Application.OnAppLinkRequestReceived/p/System.Uri/,但似乎无法让它以任何方式被调用。Xamarin.forms OnAppLinkRequestReceived

有没有人试过实施这种新方法? 我试过几种方法来实现不同的深度链接,他们都打开应用程序,以便它们正确配置,但该方法永远不会被调用。

谢谢。

+0

您可以在博客中阅读更多关于它的信息 - https://blog.xamarin.com/deep-link-content-with-xamarin-forms-url-navigation/ –

+0

我知道,那是当我第一次发现这种方法,并没有奏效。该错误去了Xamarin bugzilla https://bugzilla.xamarin.com/show_bug.cgi?id=42954。我只是推迟了这种整合,但一旦我有时间再次处理这个问题,我会尽快反馈。 – joaoasilva

回答

1

这就是我在Android中设置的方式。

将这个上面你MainActivity.cs

[IntentFilter(new[] { Android.Content.Intent.ActionView }, 
Categories = new[] 
{ 
    Android.Content.Intent.CategoryDefault, 
    Android.Content.Intent.CategoryBrowsable 
}, 
DataScheme = "http", 
DataPathPrefix = "/tesla/", 
DataHost = "exrin.net")] 

安装应用程序时,这将注册活动。将URL更改为所需的URL。

对于Android的唯一的(不需要与iOS做到这一点),你还需要安装的NuGet Xamarin Forms AppLinks

在你的OnCreate请确保您在Xamarin后做这个窗体初始化

AndroidAppLinks.Init(this); 

然后当加载的URL在浏览器中(在我的例子http://exrin.net/tesla),你会得到这样的:

enter image description here

然后,如果你打开应用程序,它将在这里输入完整的URL作为URI参数。这是App.cs(Xamarin.Forms.Application)

protected override void OnAppLinkRequestReceived(Uri uri) 
    { 
     base.OnAppLinkRequestReceived(uri); 
    } 

你认为合适的移动到你的应用程序的特定页面的URL涉及/

然后,您可以解码URI更多详细信息,请访问Xamarin Forms AppLinks

+0

嗨,亚当,我跟着你的文章,并成功实施,但有问题显示启动屏幕上的应用程序链接点击,你可以请看看这个我的问题? https://stackoverflow.com/questions/45060487/how-to-display-splash-screen-on-onapplinkrequestreceived-in-xamarin-forms-andro – batmaci