【发布时间】:2016-08-29 20:42:32
【问题描述】:
我正在开发一个带有web view 的简单UWP 页面。我想知道在浏览器中单击带有 https 协议的URL 时如何打开我的应用程序。我已经试过了:
Package.appmanifest
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="https">
<uap:Logo>Assets\Logo.png</uap:Logo>
<uap:DisplayName>test</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
App.xaml.cs
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
// Retrieves the activation Uri.
var protocolArgs = (ProtocolActivatedEventArgs)args;
var uri = protocolArgs.Uri;
var frame = Window.Current.Content as Frame;
if (frame == null)
frame = new Frame();
// Navigates to MainPage, passing the Uri to it.
frame.Navigate(typeof(MainPage), uri);
Window.Current.Content = frame;
// Ensure the current window is active
Window.Current.Activate();
}
}
但是,当单击浏览器中的链接时,我无法使用我的应用程序打开它。 有人有想法吗??
【问题讨论】:
-
你的网址是什么样的?
-
给协议名称不是 https
-
是否附加了协议?它应该是协议://页面名称
-
那是不可能的。 https 是互联网协议
-
那么当点击https协议的链接时如何打开我的应用程序?
标签: c# url browser webview win-universal-app