/// <summary> /// 更新磁贴图标 /// </summary> /// <param name="number"></param> public static void UpdateSecondaryBadgeWithGlyph(string tileId, int index) { BadgeGlyphNotificationContent badgeContent = new BadgeGlyphNotificationContent((GlyphValue)index); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badgeContent.CreateNotification()); }
public void Run(IBackgroundTaskInstance taskInstance) { if (CurrentShoppingCart == null) { return; } var badgeContent = new BadgeNumericNotificationContent((uint)CurrentShoppingCart.ItemsQuantity); BadgeUpdateManager.CreateBadgeUpdaterForApplication() .Update(badgeContent.CreateNotification()); if (CurrentShoppingCart.Items.Count > 0) { _tileSquareContent.TextBodyWrap.Text = string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity); _tileWideContent.TextHeadingWrap.Text = string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity); } else { _tileSquareContent.TextBodyWrap.Text = EMPTY_SHOPPING_CART_MESSAGE; _tileWideContent.TextHeadingWrap.Text = EMPTY_SHOPPING_CART_MESSAGE; } _tileWideContent.Square150x150Content = _tileSquareContent; TileUpdateManager.CreateTileUpdaterForApplication() .Update(_tileWideContent.CreateNotification()); }
private async void OnStartSync() { //#if DEBUG await VoIPConnection.Current.ConnectAsync(); //#endif await Toast.RegisterBackgroundTasks(); BadgeUpdateManager.CreateBadgeUpdaterForApplication("App").Clear(); TileUpdateManager.CreateTileUpdaterForApplication("App").Clear(); ToastNotificationManager.History.Clear("App"); #if !DEBUG && !PREVIEW Execute.BeginOnThreadPool(async() => { await new AppUpdateService().CheckForUpdatesAsync(); }); #endif //if (ApiInformation.IsTypePresent("Windows.ApplicationModel.FullTrustProcessLauncher")) //{ // await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); //} try { // Prepare stuff for Cortana var localVoiceCommands = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommands/VoiceCommands.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(localVoiceCommands); } catch { } }
private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { switch (args.NotificationType) { case PushNotificationType.Badge: // badge 通知 BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(args.BadgeNotification); break; case PushNotificationType.Raw: // raw 通知 // 当收到推送的 raw 通知时,如果 app 在锁屏,则可以触发后台任务以执行相关的逻辑(PushNotificationTrigger) string msg = args.RawNotification.Content; break; case PushNotificationType.Tile: // tile 通知 TileUpdateManager.CreateTileUpdaterForApplication().Update(args.TileNotification); break; case PushNotificationType.Toast: // toast 通知 ToastNotificationManager.CreateToastNotifier().Show(args.ToastNotification); break; default: break; } }
private static void UpdateBadgeGlyph(string badgeGlyphValue) { //https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-badges if (badgeGlyphValue.IsNullOrWhiteSpace()) { badgeGlyphValue = "alert"; } // Get the blank badge XML payload for a badge glyph XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph); // Set the value of the badge in the XML to our glyph value XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement; badgeElement.SetAttribute("value", badgeGlyphValue); // Create the badge notification BadgeNotification badge = new BadgeNotification(badgeXml); // Create the badge updater for the application BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); // And update the badge badgeUpdater.Update(badge); }
/// <summary> /// 更新磁贴数字 /// </summary> /// <param name="number"></param> public static void UpdateBadgeWithNumber(int number) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }
private void SetState(StateType state) { BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); string badgeGlyphValue = ""; switch (state) { case StateType.available: badgeGlyphValue = "available"; break; case StateType.away: badgeGlyphValue = "away"; break; case StateType.busy: badgeGlyphValue = "busy"; break; default: break; } XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph); XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement; badgeElement.SetAttribute("value", badgeGlyphValue); BadgeNotification badge = new BadgeNotification(badgeXml); BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); badgeUpdater.Update(badge); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { // Enable the tile queue on the primary tile (enables medium/wide/large tile queues) TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); BadgeUpdateManager.CreateBadgeUpdaterForApplication(); var shell = await Initialize(); // Place our app shell in the current Window Window.Current.Content = shell; if (shell.AppFrame.Content == null) { var facade = ServiceLocator.Current.GetInstance <INavigationFacade>(); if (AppLaunchCounter.IsFirstLaunch()) { facade.NavigateToWelcomeView(); } else { facade.NavigateToCategoriesView(); } } // Refresh launch counter, needs to be done // after AppLaunchCounter.IsFirstLaunch() is being checked. AppLaunchCounter.RegisterLaunch(); // Ensure the current window is active Window.Current.Activate(); }
private static void UpdateBadge(int badgeNumber) { #if WNS_PUSH_SERVICE var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication("xcee0f789y8059y4881y8883y347265c01f93x"); if (badgeNumber == 0) { badgeUpdater.Clear(); return; } var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge"); badgeElement.SetAttribute("value", badgeNumber.ToString()); try { badgeUpdater.Update(new BadgeNotification(badgeXml)); } catch (Exception ex) { Telegram.Logs.Log.Write(ex.ToString()); } #endif }
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; } } }
private void SendBadge_Click(object sender, RoutedEventArgs e) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage); }
private async void ButtonPinSecondaryTile_Click(object sender, RoutedEventArgs e) { _tileId = "ScenarioBadgeControl"; SecondaryTile tile = new SecondaryTile(_tileId, "Name 1", "args", new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Medium.png"), TileSize.Default); tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Small.png"); tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Wide.png"); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Large.png"); tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; await tile.RequestCreateAsync(); //Prepare for next Step: // Pop all the notifications ToastHelper.PopToast("Toast 1", "Content of Toast 1"); ToastHelper.PopToast("Toast 2", "Content of Toast 2"); ToastHelper.PopToast("Toast 3", "Content of Toast 3"); //Update badge IReadOnlyList <ToastNotification> TNList = ToastNotificationManager.History.GetHistory(); BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)TNList.Count); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(_tileId).Update(badgeContent.CreateNotification()); // Move the UI to the next step stepsControl.Step++; stepsControl.NextButtonVisibility = Visibility.Collapsed; }
// Initialize the app's tiles on the Start page. There are three different sizes of tiles users can // choose from. private void InitializeTiles() { tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); var mediumSquareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01); var largeSquareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndText02); var wideTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02); tileUpdater.EnableNotificationQueue(true); mediumSquareTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe"; largeSquareTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe"; wideTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe"; var node1 = wideTile.ImportNode(mediumSquareTile.GetElementsByTagName("binding")[0], true); wideTile.GetElementsByTagName("visual")[0].AppendChild(node1); var node2 = wideTile.ImportNode(largeSquareTile.GetElementsByTagName("binding")[0], true); wideTile.GetElementsByTagName("visual")[0].AppendChild(node2); var testNotification = new TileNotification(wideTile); testNotification.Tag = "Test"; tileUpdater.Update(testNotification); badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); }
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- public static void IncBadgeCount() { // Get the blank badge XML payload for a badge number XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); // Set the value of the badge in the XML to our number XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement; string value = null; try { value = badgeElement.GetAttribute("value"); } catch (Exception) { Logger.Debug("Failed to retrieve badge count value node."); } if (int.TryParse(value, out int count)) { badgeElement.SetAttribute("value", (count + 1).ToString()); } else { badgeElement.SetAttribute("value", "1"); } // Create the badge notification BadgeNotification badge = new BadgeNotification(badgeXml); // Create the badge updater for the application BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); // And update the badge badgeUpdater.Update(badge); }
private void pushChannel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { switch (args.NotificationType) { case PushNotificationType.Badge: // badge Notify BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(args.BadgeNotification); break; case PushNotificationType.Raw: // raw Notify string msg = args.RawNotification.Content; break; case PushNotificationType.Tile: // tile Notify TileUpdateManager.CreateTileUpdaterForApplication().Update(args.TileNotification); break; case PushNotificationType.Toast: // toast Notify ToastNotificationManager.CreateToastNotifier().Show(args.ToastNotification); break; default: break; } args.Cancel = true; }
void UpdateBadgeWithGlyphWithStringManipulation() { // Create a string with the badge template xml. string badgeXmlString = "<badge value='" + ((TileGlyph)GlyphList.SelectedItem).Name.ToString() + "'/>"; Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // Create a DOM. badgeDOM.LoadXml(badgeXmlString); // Load the xml string into the DOM, catching any invalid xml characters. BadgeNotification badge = new BadgeNotification(badgeDOM); // Create a badge notification and send it to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); OutputTextBlock.Text = badgeDOM.GetXml(); rootPage.NotifyUser("Badge sent", NotifyType.StatusMessage); } catch (Exception) { OutputTextBlock.Text = string.Empty; rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }
/// <summary> /// 更新磁贴图标 /// </summary> /// <param name="number"></param> public static void UpdateBadgeWithGlyph(int index) { BadgeGlyphNotificationContent badgeContent = new BadgeGlyphNotificationContent((GlyphValue)index); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }
//Set battery tile to disabled XmlDocument RenderTileBatteryDisabled() { try { //Reset secondary battery tile if (TileBattery_Pinned) { Debug.WriteLine("Set battery tile to disabled."); Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeBatteryTile"); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates) { try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { } } BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeBatteryTile").Clear(); string TileImage = "<group><subgroup><image src=\"ms-appx:///Assets/BatterySquare/BatteryVerNoBattery.png\"/></subgroup></group>"; string BatterySmallTile = "<binding template=\"TileSmall\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>"; string BatteryMediumTile = "<binding template=\"TileMedium\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>"; string BatteryWideTile = "<binding template=\"TileWide\">" + TileBattery_BackgroundPhotoXml + TileImage + "</binding>"; Tile_XmlContent.LoadXml("<tile><visual contentId=\"" + TileContentId + "\" branding=\"none\">" + BatterySmallTile + BatteryMediumTile + BatteryWideTile + "</visual></tile>"); Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent)); } } catch { } return(Tile_XmlContent); }
public void Run(IBackgroundTaskInstance taskInstance) { var deferal = taskInstance.GetDeferral(); if (taskInstance.TriggerDetails is RawNotification) { var details = taskInstance.TriggerDetails as RawNotification; var arguments = details.Content.Split(':'); if (arguments.Count() > 0) { switch (arguments[0]) { case "new_items": if (arguments.Count() > 1) { XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge"); badgeElement.SetAttribute("value", arguments[1]); BadgeNotification badge = new BadgeNotification(badgeXml); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); } break; } } } deferal.Complete(); }
//Set tile to failed update XmlDocument RenderTileLiveFailed(string TileId) { try { Debug.WriteLine("Set tile to failed: " + TileId); //Reset primary tile BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates) { try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { } } BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(TileId).Clear(); Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoFailed.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoFailed.png\"/></binding></visual></tile>"); Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent)); } catch { } return(Tile_XmlContent); }
private static void UpdateBadge(int badgeNumber) { var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); if (badgeNumber == 0) { badgeUpdater.Clear(); return; } var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge"); badgeElement.SetAttribute("value", badgeNumber.ToString()); try { badgeUpdater.Update(new BadgeNotification(badgeXml)); } catch (Exception ex) { Telegram.Logs.Log.Write(ex.ToString()); } }
//Set weather tile to disabled XmlDocument RenderTileWeatherDisabled() { try { //Reset secondary weather tile if (TileWeather_Pinned) { Debug.WriteLine("Set weather tile to disabled."); Tile_UpdateManager = TileUpdateManager.CreateTileUpdaterForSecondaryTile("TimeMeWeatherTile"); Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications(); foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates) { try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { } } BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile("TimeMeWeatherTile").Clear(); Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoWeatherDisabled.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoWeatherDisabled.png\"/></binding></visual></tile>"); Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent)); } } catch { } return(Tile_XmlContent); }
public static void UpdateBadgeGlyph(BadgeGlyph glyph) { // Create the badge updater for the application BadgeUpdater updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); if (glyph == BadgeGlyph.None) { updater.Clear(); } else { // Get the blank badge XML payload for a badge number XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph); // Set the value of the badge in the xml to our number XmlElement badgeElem = badgeXml.SelectSingleNode("/badge") as XmlElement; badgeElem.SetAttribute("value", glyph.DescriptionAttr()); // Create the badge notification BadgeNotification badge = new BadgeNotification(badgeXml) { ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10) }; // And update the badge updater.Update(badge); } }
/// <summary> /// 更新未读头条文章的徽章badge /// </summary> /// <param name="t"></param> private static void UpdateBadge(LatestStories t) { //将当天未读TOP文章更新到 badge int un_readed = 0; t.Top_Stories.ToList().ForEach(s => { if (!DataShareManager.Current.ReadedList.Contains(s.ID)) { un_readed++; } }); var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); if (un_readed != 0) { var badgexml = new BadgeNumericNotificationContent((uint)un_readed); var n = badgexml.CreateNotification(); n.ExpirationTime = DateTime.Now.AddDays(7); updater.Update(n); } else { updater.Clear(); } }
private void UpdateBadge(bool playing, bool paused) { try { string xmlstring; if (playing && !paused) { xmlstring = "<badge value=\"playing\"/>"; } else if (paused) { xmlstring = "<badge value=\"paused\"/>"; } else { xmlstring = "<badge value=\"stopped\"/>"; } XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xmlstring); BadgeNotification bnotification = new BadgeNotification(xdoc); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(bnotification); } catch (Exception ex) { NotifyUser(ex); } }
public static void UpdateBadge(uint count, string Id) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(count); // Send the notification to the application’s tile. Name taken from ScenarioPages.Toasts.HistoryChangedTrigger.BadgeControl BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(Id).Update(badgeContent.CreateNotification()); }
static public void UpdateWatchedBadge(WhirlMonData.WhirlPoolAPIData.RootObject data) { try { int unread = data.totalUnread; if (unread == 0) { BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); } else { XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge"); badgeElement.SetAttribute("value", unread.ToString()); BadgeNotification badge = new BadgeNotification(badgeXml); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); } } catch (Exception x) { ShowErrorToast("UpdateWatchedBadge", x); } }
private async void CreateBadgeTile_Click(object sender, RoutedEventArgs e) { if (!SecondaryTile.Exists(BADGE_TILE_ID)) { SecondaryTile secondTile = new SecondaryTile( BADGE_TILE_ID, "LockScreen CS - Badge only", "BADGE_ARGS", new Uri("ms-appx:///Assets/squareTile-sdk.png"), TileSize.Square150x150 ); secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///Assets/badgelogo-sdk.png"); bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above); if (isPinned) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2); BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(BADGE_TILE_ID).Update(new BadgeNotification(badgeContent.GetXml())); rootPage.NotifyUser("Secondary tile created and badge updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("Badge secondary tile already exists.", NotifyType.ErrorMessage); } }
public static void UpdateTile(int value) { var type = BadgeTemplateType.BadgeNumber; var xml = BadgeUpdateManager.GetTemplateContent(type); var elements = xml.GetElementsByTagName("badge"); var element = elements[0] as XmlElement; element.SetAttribute("value", value.ToString()); var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); var notification = new BadgeNotification(xml); updater.Update(notification); Debug.WriteLine("Background task badge updated: " + value.ToString()); var template = ToastTemplateType.ToastText01; xml = ToastNotificationManager.GetTemplateContent(template); var text = xml.CreateTextNode(string.Format("Badge updated to {0}", value)); elements = xml.GetElementsByTagName("text"); elements[0].AppendChild(text); var toast = new ToastNotification(xml); var notifier = ToastNotificationManager.CreateToastNotifier(); notifier.Show(toast); Debug.WriteLine("Background task toast shown: " + value.ToString()); }
/// <summary> /// 更新磁贴数字 /// </summary> /// <param name="number"></param> public static void UpdateSecondaryBadgeWithNumber(string tileId, int number) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badgeContent.CreateNotification()); }