Windows 8 平台是否有与 iOS 平台上的自定义 url 方案类似的东西?
我找到了information在 MSDN 上关于应用程序 URI 方案。这不是答案。
在我的 iPad 应用程序中,用户收到一封带有几个长键的电子邮件。用户单击 url,我的应用程序打开到正确的页面,其中填充了这些值。我错过了适用于 Windows 8 的类似功能吗?
最佳答案
您正在寻找协议(protocol)激活。
您可以通过添加 Protocol
将支持的协议(protocol)添加到 Declarations
选项卡上的 Package.appxmanifest
。这会将以下 block 添加到您的 Package.appxmanifest
文件中:
<Extensions>
<Extension Category="windows.protocol">
<Protocol Name="alrt" />
</Extension>
</Extensions>
您需要通过覆盖 OnActivated
来处理 App.xaml.cs
中的协议(protocol)激活:
protected override void OnActivated(IActivatedEventArgs args)
{
base.OnActivated(args);
if (args.Kind == ActivationKind.Protocol)
{
var protocolArgs = args as ProtocolActivatedEventArgs;
var rootFrame = new Frame();
rootFrame.Navigate(typeof(MainPage), protocolArgs.Uri.AbsoluteUri);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
}
检查 this page以获得更详细的解释。
关于windows-8 - 适用于 Windows 8 的自定义 URL 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14804323/