2017-01-18 16 views
0

このチュートリアルの後にUWPアプリケーション用の通知ハブを使用しています:Getting started with Notification Hubs for Windows Universal Platform AppsAzure通知ハブUWP、UWPトースト通知がアプリを起動しない

私のようなWindows 8の通知を送ってテストする場合:

<?xml version="1.0" encoding="utf-8"?> 
<toast> 
<visual><binding template="ToastText01"> 
<text id="1">Test message</text> 
</binding> 
</visual> 
</toast> 

それは作品と私は通知をクリックした場合、それはOnLaunched()メソッドを介してアプリを開きます。私が好きUWP特定の通知を送信する場合しかし:)

<toast launch="app-defined-string"> 
<visual> 
<binding template="ToastGeneric"> 
    <text>Microsoft Company Store</text> 
    <text>New Halo game is back in stock!</text> 
</binding> 
</visual> 
<actions> 
<action activationType="foreground" content="See more details" arguments="details"/> 
<action activationType="background" content="Remind me later" arguments="later"/> 
</actions> 
</toast> 

トーストの作品が、私はそれをクリックした場合、それはアプリを開いて、(OnLaunchedアプリはspashscreenに貼り付けて呼び出されることはありません。あなたは

protected override void OnActivated(IActivatedEventArgs args) 
     { 
      base.OnActivated(args); 
     } 

あなたapp.xaml.csでOnActivatedを実装する必要が

よろしく

答えて

0

を参照してください、あなたの助けを事前に

おかげで、同じ問題、Dave Smitsの答え:JusteはApp.xaml.csファイルのOnZctivatedメソッドを追加し、OnLaunchedメソッドと同じコンテンツを配置します:

protected override async void OnLaunched(LaunchActivatedEventArgs e) 
    { 
     await OnLaunchedOrActivated(e); 
    } 

protected override async void OnActivated(IActivatedEventArgs e) 
    { 
     await OnLaunchedOrActivated(e); 
    } 

private async Task OnLaunchedOrActivated(IActivatedEventArgs e) 
    { 
     // Initialize things like registering background task before the app is loaded 

     Frame rootFrame = Window.Current.Content as Frame; 

     // Do not repeat app initialization when the Window already has content, 
     // just ensure that the window is active 
     if (rootFrame == null) 
     { 
      // Create a Frame to act as the navigation context and navigate to the first page 
      rootFrame = new Frame(); 

      rootFrame.NavigationFailed += OnNavigationFailed; 

      if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 
      { 
       // TODO: Load state from previously suspended application 
      } 

      // Place the frame in the current Window 
      Window.Current.Content = rootFrame; 
     } 

     // Handle toast activation 
     if (e is ToastNotificationActivatedEventArgs) 
     { 
      var toastActivationArgs = e as ToastNotificationActivatedEventArgs; 

      // If empty args, no specific action (just launch the app) 
      if (toastActivationArgs.Argument.Length == 0) 
      { 
       if (rootFrame.Content == null) 
        rootFrame.Navigate(typeof(MainPage)); 
      } 
      // Otherwise an action is provided 
      else 
      { 
       // Parse the query string 


       // See what action is being requested 

       // If we're loading the app for the first time, place the main page on the back stack 
       // so that user can go back after they've been navigated to the specific page 
       if (rootFrame.BackStack.Count == 0) 
        rootFrame.BackStack.Add(new PageStackEntry(typeof(MainPage), null, null)); 
      } 
     } 

     // Handle launch activation 
     else if (e is LaunchActivatedEventArgs) 
     { 
      var launchActivationArgs = e as LaunchActivatedEventArgs; 

      // If launched with arguments (not a normal primary tile/applist launch) 
      if (launchActivationArgs.Arguments.Length > 0) 
      { 
       // TODO: Handle arguments for cases like launching from secondary Tile, so we navigate to the correct page 
       throw new NotImplementedException(); 
      } 

      // Otherwise if launched normally 
      else 
      { 
       // If we're currently not on a page, navigate to the main page 
       if (rootFrame.Content == null) 
        rootFrame.Navigate(typeof(MainPage)); 
      } 
     } 

     else 
     { 
      // TODO: Handle other types of activation 
      throw new NotImplementedException(); 
     } 


     // Ensure the current window is active 
     Window.Current.Activate(); 
    } 
関連する問題