我正在开发一个带有 WebView
的简单UWP
页面。我想知道当在浏览器中单击带有 https 协议(protocol)的 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();
}
}
但是,当单击浏览器中的链接时,我无法选择使用我的应用程序打开它。 有人有想法吗??
最佳答案
您无法将应用程序绑定(bind)到内部协议(protocol)(例如 http
/https
)。
关于c# - 在浏览器中单击 URL 时打开 UWP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37027244/