private void BuildNotifications(IList <Notifications> notifications) { List <Notifications> filteredNotifications = notifications.Where(n => !n.content.StartsWith("You")).ToList(); var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); badgeUpdater.Clear(); var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.EnableNotificationQueue(true); tileUpdater.Clear(); BadgeNumericContent badgeContent = new BadgeNumericContent((uint)filteredNotifications.Count); badgeUpdater.Update(new BadgeNotification(badgeContent.GetXml())); ToastNotificationManager.ConfigureNotificationMirroring(NotificationMirroring.Allowed); // Keep track of the number feed items that get tile notifications. int itemCount = 0; // Create a tile notification for each feed item. foreach (var notification in filteredNotifications) { // Create a new tile notification. tileUpdater.Update(new TileNotification(GenerateTileContent(notification).GetXml())); ToastNotification toastNotification = new ToastNotification(GenerateToastContent(notification).GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toastNotification); // Don't create more than 5 notifications. if (itemCount++ > 5) { break; } } }
public Task SetBadge(int value) { var badge = new BadgeNumericContent((uint)value); this.badgeUpdater.Update(new BadgeNotification(badge.GetXml())); this.settings.Set(BADGE_KEY, value); return(Task.CompletedTask); }
public async Task Send(Notification notification) { if (notification.Id == 0) { notification.Id = this.settings.IncrementValue("NotificationId"); } if (notification.ScheduleDate != null) { await this.repository.Set(notification.Id.ToString(), notification); return; } var toastContent = new ToastContent { Duration = notification.Windows.UseLongDuration ? ToastDuration.Long : ToastDuration.Short, Launch = notification.Payload, ActivationType = ToastActivationType.Background, Visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = notification.Title }, new AdaptiveText { Text = notification.Message } } } } }; if (!Notification.CustomSoundFilePath.IsEmpty()) { toastContent.Audio = new ToastAudio { Src = new Uri(Notification.CustomSoundFilePath) } } ; this.toastNotifier.Show(new ToastNotification(toastContent.GetXml())); var badge = new BadgeNumericContent((uint)notification.BadgeCount); this.badgeUpdater.Update(new BadgeNotification(badge.GetXml())); await this.services.SafeResolveAndExecute <INotificationDelegate>(x => x.OnReceived(notification)); }
public void UpdateBadge() { int count = GetItemsForCurrentSettings().Count; if (!Settings.LiveTile.BadgeIsEnabled) { count = 0; } _logging.WriteLine($"Updating badge with number {count}."); var badgeManager = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); var content = new BadgeNumericContent((uint)count); badgeManager.Update(new BadgeNotification(content.GetXml())); }
public async Task UpdateScheduleSummaryNotificationAsync() { if (!ShouldUpdateScheduleSummary) { return; } List <ScheduleEntryViewModel> schedule; try { schedule = await GetTodayScheduleAsync(); } catch (LocalCacheRequestFailedException) { return; } TileUpdateManager.CreateTileUpdaterForApplication().Clear(); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); if (schedule.Count == 0) { return; } var tile = new TileContent() { Visual = new TileVisual() { TileSmall = new TileBinding() { Content = new TileBindingContentIconic() }, TileMedium = GetTile(schedule, TileSize.Medium), TileWide = GetTile(schedule, TileSize.Wide), TileLarge = GetTile(schedule, TileSize.Large), LockDetailedStatus1 = schedule[0].Name, LockDetailedStatus2 = schedule[0].TimeRangeDisplay, LockDetailedStatus3 = schedule[0].Room } }; var tileNotification = new TileNotification(tile.GetXml()); tileNotification.ExpirationTime = schedule[0].LocalEndTime; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); var badge = new BadgeNumericContent((uint)schedule.Count); var badgeNotification = new BadgeNotification(badge.GetXml()); badgeNotification.ExpirationTime = schedule[0].LocalEndTime; BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification); if (ShouldSendScheduleSummaryToast) { ToastContent toast = GetToast(schedule); var toastNotification = new ToastNotification(toast.GetXml()) { Group = ToastTypes.ScheduleSummary.ToString(), Tag = Guid.NewGuid().ToString(), ExpirationTime = schedule.Max(x => x.LocalEndTime) }; ToastNotificationManager.CreateToastNotifier().Show(toastNotification); SetScheduleSummaryToastSentStatus(); } }