UWP中的Azure通知中心

时间:2017-08-15 13:47:25

标签: azure notifications uwp

我通过Azure Notification中心向ASP.NET网站提供UWP应用程序的通知,但是当我点击通知时它会打开应用程序并暂停在启动画面中然后立即关闭,我如何解决这个问题?

我使用本教程: https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-windows-store-dotnet-get-started-wns-push-notification

1 个答案:

答案 0 :(得分:1)

  

当我点击通知时,它会打开应用并在启动画面中暂停,然后立即关闭

当启动UWP应用程序并初始创建此方法时,通常会调用OnLaunched。但是,如果您想通过ActivationKindToastNotification的吐司启动应用,则可能需要通过覆盖OnActivated事件句柄来处理激活的事件。例如:

protected override void OnActivated(IActivatedEventArgs args)
{
    if (args.Kind == ActivationKind.ToastNotification)
    {
        ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
        // TODO: Handle URI activation
        // The received URI is eventArgs.Uri.AbsoluteUri
        var rootFrame = CreateRootFrame();
        rootFrame.Navigate(typeof(MainPage));
        Window.Current.Activate();
    }
}

更多详情请参阅Handle URI activationNotification official sample

相关问题