private async void Button_ResetNotifications(object sender, RoutedEventArgs e)
        {
            await NotificationUtils.ClearNotifications();

            await NotificationUtils.SyncNotifications();

            ContentDialog dialog = new ContentDialog
            {
                Title           = "Reset done",
                Content         = "Your notifications have been resent to the api!",
                CloseButtonText = "Ok"
            };

            ContentDialogResult result = await dialog.ShowAsync();
        }
Ejemplo n.º 2
0
        protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            var deferral = args.TaskInstance.GetDeferral();

            switch (args.TaskInstance.Task.Name)
            {
            case "UserNotificationChanged":
                await Requests.Post("http://localhost:80/log", "{\"state\": \"activatedfrombackground\"}");

                await NotificationUtils.SyncNotifications();

                break;
            }

            deferral.Complete();
        }
        private async void Button_CheckAPIConnection(object sender, RoutedEventArgs e)
        {
            try
            {
                bool success = await NotificationUtils.CheckAPIConnection();

                ContentDialog dialog = new ContentDialog
                {
                    Title           = success ? "Check succeeded!" : "Check failed!",
                    Content         = "API connection check finished.",
                    CloseButtonText = "Close"
                };

                _ = await dialog.ShowAsync();
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // App-Initialisierung nicht wiederholen, wenn das Fenster bereits Inhalte enthält.
            // Nur sicherstellen, dass das Fenster aktiv ist.
            if (rootFrame == null)
            {
                // Frame erstellen, der als Navigationskontext fungiert und zum Parameter der ersten Seite navigieren
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Zustand von zuvor angehaltener Anwendung laden
                }

                // Den Frame im aktuellen Fenster platzieren
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren
                    // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter
                    // übergeben werden
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Sicherstellen, dass das aktuelle Fenster aktiv ist
                Window.Current.Activate();
            }

            if (await NotificationUtils.RegisterBackgroundProcess())
            {
                await Requests.Post("http://localhost:80/log", "{\"state\": \"launched\"}");

                await NotificationUtils.SyncNotifications();
            }
        }