LaunchUriAsync 仅适用于在 PushNotificationTrigger BackgroundTask 中连接的调试器

LaunchUriAsync is working only with debugger connected in PushNotificationTrigger BackgroundTask

目前,我们正尝试在用户接受 VOIP 呼叫时使用 LaunchUriAsync 从 PushNotificationTrigger BackgroundTask 启动应用程序。 LaunchUriAsync 仅与附加的调试器一起工作,一旦分离调试器 LaunchUriAsync 就停止启动应用程序。重新连接到进程后,它又开始工作了。

public sealed class PushNotificationReciever : IBackgroundTask
    {

        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
            RawNotification notification = (RawNotification)taskInstance.TriggerDetails;
            await Windows.System.Launcher.LaunchUriAsync(new Uri("custom:\data"));
            deferral.Complete();
        }
    }

documentation 状态:

Unless you are calling this API from a Windows desktop application, this API must be called from within an ASTA thread (also known as the UI thread).

您不能从后台任务执行此操作。

来自后台任务的

LaunchUriAsync 适用于我的目标版本 1803。更改为 1809 及更高版本会破坏它。