//Als de gebruiker op de toast/notification klikt protected override async void OnActivated(IActivatedEventArgs e) { //De rootframe ophalen Frame rootFrame = Window.Current.Content as Frame; //TODO: initialiseren van root frame, net als in OnLaunched //Toast Activation opvangen if (e is ToastNotificationActivatedEventArgs) { var toastActivationArgs = e as ToastNotificationActivatedEventArgs; QueryString args = QueryString.Parse(toastActivationArgs.Argument); //Kijk welke actie gevraagd is switch (args["action"]) { case "viewBob": Dialog dialog = new Dialog() { Message= args["message"], Ok=args["ok"], Nok=args["nok"], ViewOk= JsonConvert.DeserializeObject<Type>(args["viewOk"]), ViewNok= JsonConvert.DeserializeObject<Type>(args["viewNok"]), ParamView= JsonConvert.DeserializeObject<object>(args["paramView"]), Cb=args["cb"], Data = args["data"] }; Task task = ShowDialog(dialog.Message, dialog.Ok, dialog.Nok, dialog.ViewOk, dialog.ViewNok, dialog.ParamView, dialog.Cb, dialog.Data); break; case "ok": string ok = args["value"]; Type viewOk= JsonConvert.DeserializeObject<Type>(args["viewOk"]); object paramView = JsonConvert.DeserializeObject<object>(args["paramView"]); object data = JsonConvert.DeserializeObject<object>(args["data"]); string cb = args["cb"]; if (viewOk != null) { Frame mainFrame = MainViewVM.MainFrame as Frame; mainFrame.Navigate(viewOk, paramView); } if (cb != null) { Messenger.Default.Send<NavigateTo>(new NavigateTo() { Name = cb, Result = true, ParamView = paramView, Data= data }); } break; case "nok": string nok = args["value"]; Type viewNok = JsonConvert.DeserializeObject<Type>(args["viewNok"]); object _paramView = JsonConvert.DeserializeObject<object>(args["paramView"]); object _data = JsonConvert.DeserializeObject<object>(args["data"]); string _cb = args["cb"]; if (viewNok != null) { Frame mainFrame = MainViewVM.MainFrame as Frame; mainFrame.Navigate(viewNok, _paramView); } if (_cb != null) { Messenger.Default.Send<NavigateTo>(new NavigateTo() { Name = _cb, Result = false, ParamView = _paramView, Data=_data }); } break; //Open de application case "openBobApp": //Nog uitzoeken hoe je dat moet doen, nog niet zo heel belangrijk break; //Open het scherm waar je toestemming geeft om je locatie te gebruiken. case "openLocationServices": await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location")); break; } } //Maak zeker dat het scherm nu actief is Window.Current.Activate(); }
private async void DialogChange(Dialog dialog) { if (dialog.Message != null) { #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,async () => { var test = Window.Current.CoreWindow.Visible; if (IsMinimized == true || dialog.IsNotification==true) { bool ok = Toast.Show(dialog.Message, dialog.Ok, dialog.Nok, dialog.ViewOk, dialog.ViewNok, dialog.ParamView, dialog.Cb, dialog.Data); } else { Task task = ShowDialog(dialog.Message, dialog.Ok, dialog.Nok, dialog.ViewOk, dialog.ViewNok, dialog.ParamView, dialog.Cb,dialog.Data); } }); #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously } }