示例#1
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();

            //IDataService dataService = new RealService();
            IDataService    dataService     = new FakeService();
            SettingsService settingsService = new SettingsService();

            if (dataService.IsLoggedIn() && settingsService.GetBackgroundTaskEnabledSetting())
            {
                List <Models.Notification> notifications = dataService.GetNotifications();

                notifications.FindAll(n => n.IsUnread).ForEach(n => {
                    Debug.WriteLine(DateTime.Now + " - " + n.Message);
                    ShowNotification("Title", n.Message);
                });
            }

            _deferral.Complete();
        }
示例#2
0
        // Background task

        protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
        {
            base.OnBackgroundActivated(args);
            IBackgroundTaskInstance taskInstance = args.TaskInstance;
            BackgroundTaskDeferral  _deferral    = taskInstance.GetDeferral();

            //IDataService dataService = new RealService();
            IDataService    dataService     = new FakeService();
            SettingsService settingsService = new SettingsService();

            if (dataService.IsLoggedIn() && settingsService.GetBackgroundTaskEnabledSetting())
            {
                List <Models.Notification> notifications = await dataService.GetNotifications();

                notifications.FindAll(n => n.IsUnread).ForEach(n => {
                    Debug.WriteLine(DateTime.Now + " - " + n.Message);
                    string title = "Wishlist Notification";
                    switch (n.Type)
                    {
                    case NotificationType.DeadlineReminder:
                        title = "Wishlist Deadline Reminder";
                        break;

                    case NotificationType.JoinRequest:
                        title = "Join Wishlist Request";
                        break;

                    case NotificationType.ListInvitation:
                        title = "Wishlist Invitation";
                        break;
                    }
                    ShowNotification(title, n.Message);
                });
            }

            _deferral.Complete();
        }