UWP中的Azure通知中心

问题描述:

我通过Azure通知中心向ASP.NET网站的UWP应用程序发出通知,但当我点击通知时,它会打开应用程序并在启动屏幕中暂停,然后立即关闭,我如何解决此问题?UWP中的Azure通知中心

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

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

通常情况下,OnLaunched是当UWP启动应用程序时调用并且这种方法是最初创建的。但是,如果您想通过烤面包启动应用程序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