当 LaunchQuerySupportType 为 UriForResults 时的 NotSupported 结果

NotSupported result when LaunchQuerySupportType is UriForResults

我有一个 UWP 应用程序,我在其中定义了自定义协议。我目前正在使用 LaunchUriForResultsAsync 通过另一个应用程序启动该应用程序,并毫无问题地收到预期的响应:

var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = TARGET_PACKAGE;
var launchResults = await Launcher.LaunchUriForResultsAsync(new Uri($"myprotocol:?b={cids}"), options);

但是,当我想查询是否安装了可以处理 myprotocol: 的应用程序时,我没有得到预期的结果。

第一种方法,按预期使用LaunchQuerySupportType.UrireturnsSupported

var queryResult = await Launcher.QueryUriSupportAsync(new Uri("myprotocol:"), LaunchQuerySupportType.Uri, TARGET_PACKAGE);

当使用 LaunchQuerySupportType.UriForResults 时,我得到 NotSupported 返回。

var queryResult = await Launcher.QueryUriSupportAsync(new Uri("myprotocol:"), LaunchQuerySupportType.UriForResults, TARGET_PACKAGE);

实现自定义协议的应用程序清单中是否缺少我的标志?我在这里错过了什么?

(参见 QueryUriSupportAsync

答案通常只在发布问题后出现 :p

在设置协议

时,Package.appxmanifest 的 GUI 中没有公开一个 ReturnResults 属性

协议扩展中的 ReturnResults 属性接受以下值之一:

  • 可选—可以使用 LaunchUriForResultsAsync 方法针对结果启动应用程序,或者使用 LaunchUriAsync 不针对结果启动应用程序。当你使用optional时,启动的应用必须判断是否启动了结果。它可以通过检查 OnActivated 事件参数来做到这一点。如果参数的 IActivatedEventArgs.Kind 属性 returns ActivationKind.ProtocolForResults,或者如果事件参数的类型是 ProtocolActivatedEventArgs,应用程序是通过 LaunchUriForResultsAsync 启动的。
  • always—该应用只能为结果启动;也就是说,它只能响应 LaunchUriForResultsAsync.
  • none—结果无法启动应用;它只能响应 LaunchUriAsync.

(参见 How to launch an app for results