protected override async void OnActivated(IActivatedEventArgs args) { Logger.LogInformation("OnActivated() {0}", args.GetType()); if (args is ToastNotificationActivatedEventArgs toastArgs) { bool createdMainWindow = await CreateMainWindow(toastArgs.Argument); if (!createdMainWindow) { if (args is IViewSwitcherProvider viewSwitcherProvider && viewSwitcherProvider.ViewSwitcher != null) { ActivationViewSwitcher switcher = viewSwitcherProvider.ViewSwitcher; int currentId = toastArgs.CurrentlyShownApplicationViewId; if (viewSwitcherProvider.ViewSwitcher.IsViewPresentedOnActivationVirtualDesktop(toastArgs.CurrentlyShownApplicationViewId)) { await Views[currentId].Dispatcher.RunTaskAsync(() => { Logger.LogInformation("OnActivated() selecting conversation"); Views[currentId].Locator.MainPageInstance.SelectConversation(toastArgs.Argument); }); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(currentId); } else { await CreateSecondaryWindow(switcher, toastArgs.Argument); } } else { Logger.LogError("OnActivated() has no ViewSwitcher"); } } }
protected override async void OnActivated(IActivatedEventArgs args) { Logger.LogInformation("OnActivated() {0}", args.GetType()); DisappearingMessagesManager.DeleteExpiredMessages(); if (args is ToastNotificationActivatedEventArgs toastArgs) { string requestedConversation = toastArgs.Argument; bool createdMainWindow = await CreateMainWindow(requestedConversation); if (!createdMainWindow) { if (args is IViewSwitcherProvider viewSwitcherProvider && viewSwitcherProvider.ViewSwitcher != null) { ActivationViewSwitcher switcher = viewSwitcherProvider.ViewSwitcher; int currentId = toastArgs.CurrentlyShownApplicationViewId; if (viewSwitcherProvider.ViewSwitcher.IsViewPresentedOnActivationVirtualDesktop(toastArgs.CurrentlyShownApplicationViewId)) { var taskCompletionSource = new TaskCompletionSource <bool>(); await Views[currentId].Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { Logger.LogInformation("OnActivated() selecting conversation"); Views[currentId].Locator.MainPageInstance.TrySelectConversation(requestedConversation); } catch (Exception e) { Logger.LogError("OnActivated() TrySelectConversation() failed: {0}\n{1}", e.Message, e.StackTrace); } finally { taskCompletionSource.SetResult(false); } }); await taskCompletionSource.Task; await viewSwitcherProvider.ViewSwitcher.ShowAsStandaloneAsync(currentId); } else { await CreateSecondaryWindowOrShowMain(switcher, requestedConversation); } } else { Logger.LogError("OnActivated() has no ViewSwitcher"); } } }
protected override void OnActivated(IActivatedEventArgs e) { if (e.GetType() == typeof(ToastNotificationActivatedEventArgs)) { Console.WriteLine(e is ToastNotificationActivatedEventArgs); var toastActivationArgs = (ToastNotificationActivatedEventArgs)e; ToastArguments args = ToastArguments.Parse(toastActivationArgs.Argument); var JsonString = args.Contains("lesson") ? args["lesson"] : null; if (JsonString != null) { var lesson = JsonConvert.DeserializeObject <Lesson>(JsonString, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); lesson.EnterClass(new StudentInfo() { Name = Settings.UserName }); } } }
protected override void OnActivated(IActivatedEventArgs e) { try { if (DeviceUtil.IsXbox) { Helper.FullscreenModeInXbox(); } } catch { } if (e.Kind == ActivationKind.Protocol) { var uriArgs = e as ProtocolActivatedEventArgs; System.Diagnostics.Debug.WriteLine("URI>>>>>> " + uriArgs.Uri.ToString()); MainPage.NavigationUriProtocol = uriArgs.Uri.ToString(); // Ensure the current window is active //Window.Current.Activate(); Frame rootFrame = CreateRootFrame(); if (rootFrame.Content == null) //if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); SplashView extendedSplash = new SplashView(e.SplashScreen, loadState); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } // Place the frame in the current Window Window.Current.Content = rootFrame; } else { MainPage.Current?.HandleUriProtocol(); } rootFrame.Content.GetType().PrintDebug(); Window.Current.Content.GetType().PrintDebug(); Window.Current.Activate(); } else if (e.Kind == ActivationKind.ToastNotification) { e.GetType().PrintDebug(); var args = e as ToastNotificationActivatedEventArgs; args.PrintDebug(); Frame rootFrame = CreateRootFrame(); if (rootFrame.Content == null) //if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); SplashView extendedSplash = new SplashView(e.SplashScreen, loadState); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } // Place the frame in the current Window Window.Current.Content = rootFrame; } else { MainPage.Current?.HandleUriProtocol(); } rootFrame.Content.GetType().PrintDebug(); Window.Current.Content.GetType().PrintDebug(); Window.Current.Activate(); } }
/// <summary> /// Handle activation of the event and any navigation necessary. /// </summary> /// <param name="e">Activation args.</param> /// <param name="rootFrame">Root frame of the app.</param> public void HandleActivation(IActivatedEventArgs e, Frame rootFrame) { var handled = false; try { PlatformBase.CurrentCore.Analytics.Event("HandleActivation", e.Kind); switch (e.Kind) { case ActivationKind.Launch: var launchArg = e as LaunchActivatedEventArgs; PlatformBase.CurrentCore.Logger.Log(LogLevels.Warning, "Calling OnActivation({0}) TileID: {1} Arguments: {2}", e?.GetType().Name, launchArg.TileId, launchArg.Arguments); handled = this.OnActivation(launchArg); break; case ActivationKind.VoiceCommand: var voiceArgs = e as VoiceCommandActivatedEventArgs; PlatformBase.CurrentCore.Logger.Log(LogLevels.Warning, "Calling OnActivation({0})", e?.GetType().Name); handled = this.OnActivation(voiceArgs); break; case ActivationKind.ToastNotification: var toastArgs = e as ToastNotificationActivatedEventArgs; PlatformBase.CurrentCore.Logger.Log(LogLevels.Warning, "Calling OnActivation({0}) Arguments: {1}", e?.GetType().Name, toastArgs.Argument); handled = this.OnActivation(toastArgs); break; case ActivationKind.Protocol: var protocolArgs = e as ProtocolActivatedEventArgs; PlatformBase.CurrentCore.Logger.Log(LogLevels.Warning, "Calling OnActivation({0}) Arguments: {1}", e?.GetType().Name, protocolArgs.Uri.ToString()); handled = this.OnActivation(protocolArgs); break; default: PlatformBase.CurrentCore.Logger.LogError(new Exception(string.Format("Can't call OnActivation({0}) as it's not implemented!", e.Kind))); handled = false; break; } if (handled == false || rootFrame?.Content == null) { this.Home(); } PlatformBase.CurrentCore.Logger.Log(LogLevels.Information, "Completed Navigation.HandleActivation({0}) on RootFrame: {1} --- OnActivation Handled? {2}", e?.GetType().Name, rootFrame?.Content?.GetType().Name, handled); } catch (Exception ex) { PlatformBase.CurrentCore.Logger.LogError(ex, "Error during App Navigation.HandleActivation({0}) on RootFrame: {1}", e?.GetType().Name, rootFrame?.Content?.GetType().Name); throw ex; } }
protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { var logger = SLWIOC.Get <ILogger>(); var protocolActivatedEventArgs = (args as ProtocolActivatedEventArgs); if (protocolActivatedEventArgs == null) { logger.AddCustomEvent(LogLevel.Error, "App_OnActivated", "EventArgs Not ProtocolActivatedEventArgs", new System.Collections.Generic.KeyValuePair <string, string>("type", args.GetType().Name)); } else { logger.AddCustomEvent(LogLevel.Message, "App_OnActivated", "URI App Activation", new System.Collections.Generic.KeyValuePair <string, string>("uri", protocolActivatedEventArgs.Uri.ToString())); LagoVista.Simulator.App.Instance.HandleURIActivation(protocolActivatedEventArgs.Uri); } } base.OnActivated(args); }
private void ActivateForeground(IActivatedEventArgs args) { INavigationService navigationController = Services.Resolve <INavigationService>(); IViewProvider viewProvider = Services.Resolve <IViewProvider>(); viewProvider.StartUI(); if (Services.IsRegistered <IShellHandler>()) { navigationController.Navigate <IShellHandler>(NavigationProperties.Shell); } var activationHandler = Services.Resolve <IActivationHandler>(); var activateViewModel = activationHandler.GetViewModel(args); if (activateViewModel != null) { navigationController.Navigate(activateViewModel, args); } else { throw new LifecycleException($"No activation service could be found to handle the {args?.GetType().Name} IActivatedEventArgs."); } }
protected override async void OnActivated(IActivatedEventArgs args) { Logger.LogInformation("OnActivated() {0}", args.GetType()); if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; // We support multiple protocols so check what scheme was used to launch the app if (protocolArgs.Uri.Scheme.ToLower() == "signalpassback") { if (protocolArgs.Data.ContainsKey("token")) { string signalCaptchaToken = (string)protocolArgs.Data["token"]; var registerPageInstance = CurrentSignalWindowsFrontend(MainViewId).Locator.RegisterPageInstance; registerPageInstance.CaptchaCode = signalCaptchaToken; registerPageInstance.CaptchaWebViewEnabled = false; CurrentSignalWindowsFrontend(MainViewId).Locator.CaptchaPageInstance.View.Frame.GoBack(); } else { Logger.LogError("App was launched with signalpassback:// but wasn't passed a token"); } return; } } DisappearingMessagesManager.DeleteExpiredMessages(); if (args is ToastNotificationActivatedEventArgs toastArgs) { string requestedConversation = toastArgs.Argument; bool createdMainWindow = await CreateMainWindow(requestedConversation); if (!createdMainWindow) { if (args is IViewSwitcherProvider viewSwitcherProvider && viewSwitcherProvider.ViewSwitcher != null) { ActivationViewSwitcher switcher = viewSwitcherProvider.ViewSwitcher; int currentId = toastArgs.CurrentlyShownApplicationViewId; if (viewSwitcherProvider.ViewSwitcher.IsViewPresentedOnActivationVirtualDesktop(toastArgs.CurrentlyShownApplicationViewId)) { var taskCompletionSource = new TaskCompletionSource <bool>(); await Views[currentId].Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { Logger.LogInformation("OnActivated() selecting conversation"); Views[currentId].Locator.MainPageInstance.TrySelectConversation(requestedConversation); } catch (Exception e) { Logger.LogError("OnActivated() TrySelectConversation() failed: {0}\n{1}", e.Message, e.StackTrace); } finally { taskCompletionSource.SetResult(false); } }); await taskCompletionSource.Task; await viewSwitcherProvider.ViewSwitcher.ShowAsStandaloneAsync(currentId); } else { await CreateSecondaryWindowOrShowMain(switcher, requestedConversation); } } else { Logger.LogError("OnActivated() has no ViewSwitcher"); } } }
protected override async void OnActivated(IActivatedEventArgs e) { if (Helper.DontUseTimersAndOtherStuff) { return; } try { if (DeviceUtil.IsXbox) { Helper.FullscreenModeInXbox(); } } catch { } if (e.Kind == ActivationKind.Protocol) { var uriArgs = e as ProtocolActivatedEventArgs; Debug.WriteLine("URI>>>>>> " + uriArgs.Uri.ToString()); MainPage.NavigationUriProtocol = uriArgs.Uri.ToString(); // Ensure the current window is active //Window.Current.Activate(); Frame rootFrame = CreateRootFrame(); if (rootFrame.Content == null) //if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { SplashView extendedSplash = new SplashView(e.SplashScreen); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } // Place the frame in the current Window Window.Current.Content = rootFrame; } else { MainPage.Current?.HandleUriProtocol(); } rootFrame.Content.GetType().PrintDebug(); Window.Current.Content.GetType().PrintDebug(); Window.Current.Activate(); } else if (e.Kind == ActivationKind.ToastNotification) { e.GetType().PrintDebug(); var args = e as ToastNotificationActivatedEventArgs; args.PrintDebug(); Debug.WriteLine("--------------------+OnActivated+------------------"); Debug.WriteLine(args.Argument); Debug.WriteLine("UserInput: "); if (args?.UserInput?.Count > 0) { foreach (var val in args.UserInput) { Debug.WriteLine(val.Key + " : " + JsonConvert.SerializeObject(val.Value)); } } Debug.WriteLine("--------------------+------------------"); Frame rootFrame = CreateRootFrame(); bool wait = false; if (rootFrame.Content == null) { wait = true; // Create a Frame to act as the navigation context and navigate to the first page rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { SplashView extendedSplash = new SplashView(e.SplashScreen); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } // Place the frame in the current Window Window.Current.Content = rootFrame; } else { HandleActivation(args, false); MainPage.Current?.HandleUriProtocol(); } rootFrame.Content.GetType().PrintDebug(); Window.Current.Content.GetType().PrintDebug(); Window.Current.Activate(); // wait if (wait) { await Task.Delay(3500); HandleActivation(args, true); } } }