2017-08-15 60 views

回答

1

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

通常情况下,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

相关问题