public static void CreateToastNotification(Notification notification) { ToastContent content; switch (notification.Type) { case "mention": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} mentioned you", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "reblog": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} boosted your status", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "favourite": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} favourited your status", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "follow": content = CreateFollowToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} followed you", notification.Account); break; default: throw new Exception("Unknown type"); } XmlDocument doc = content.GetXml(); var toastNotification = new ToastNotification(doc); var nameProperty = toastNotification.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "Tag"); nameProperty?.SetValue(toastNotification, notification.Type); ToastNotificationManager.CreateToastNotifier().Show(toastNotification); }
public static void CreateNotificationLiveTile(Notification notification) { var notificationString = ""; var notificationSubstring = ""; switch (notification.Type) { case "mention": notificationString = $"↩️ {notification.Account.AccountName}"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "reblog": notificationString = $"🔁 {notification.Account.AccountName}"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "favourite": notificationString = $"⭐ {notification.Account.AccountName} favourited your status"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "follow": notificationString = $"New Follower:"; notificationSubstring = $"{notification.Account.AccountName}"; break; } var content = new TileContent() { Visual = new TileVisual() { TileMedium = CreateMediumTitleBinding(notificationString, notificationSubstring), TileWide = CreateWideTitleBinding(notification.Account.AvatarUrl, notificationString, notificationSubstring), TileLarge = CreateLargeTitleBinding(notification.Account.AvatarUrl, notificationString, notificationSubstring) } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }