Exemplo n.º 1
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            StartApp(args.PreviousExecutionState);
            PushServicesExtensions.HandlePushActivation(args, Mvx.Resolve <IUniversalWindowsRemoteNotificationsPresenter>());
        }
Exemplo n.º 2
0
        protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            base.OnBackgroundActivated(args);

            // you have to create those services manually as IoC Provider is not ready yet...
            // application is launched from background (it ws closed before executing that)
            // mvvmcross does not have good bakground actiation support for UWP..

            IUniversalWindowsRemoteNotificationsPresenter remoteNotificationsPresenter =
                new UniversalWindowsRemoteNotificationsPresenter(new UWPRemoteNotificationIdProvider(), new UniversalWindowsPresenterConfiguration(
                                                                     new BadgeNotificationsIdProvider(),
                                                                     new ToastNotificationsIdProvider(),
                                                                     new TileNotificationsIdProvider()
                                                                     ));
            INotificationsService notificationsService =
                new UWPRemotePushNotificationsService(new BackendBasedRemotePushRegistrationService(new AppRestService(() => new HttpClient())),
                                                      new PushTagsProviderService(), remoteNotificationsPresenter);

            PushServicesExtensions.HandlePushRelatedBackgroundActivation(args, remoteNotificationsPresenter, notificationsService);
        }
Exemplo n.º 3
0
        private void StartApp(ApplicationExecutionState e)
        {
            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 == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

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

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                var applicationSetup = new WindowsApplicationSetup(rootFrame);
                applicationSetup.EnsureInitialized(typeof(WindowsApplicationSetup));
                var applicationStart = Mvx.Resolve <IMvxAppStart>();
                applicationStart.Start();
            }
            PushServicesExtensions.SetupNotificationsIfNeeded(Mvx.Resolve <INotificationsService>(),
                                                              Mvx.Resolve <IUniversalWindowsRemoteNotificationsPresenter>());

            // Ensure the current window is active
            Window.Current.Activate();
        }