1

我想在我的 Windows 8 应用程序中的磁贴上显示一个徽章。我尝试了以下代码,但没有在磁贴中获取徽章。没有出现错误。我不明白问题是什么。我坚持了 2 个小时。

 var notifications = Windows.UI.Notifications;  
 var badgeType = notifications.BadgeTemplateType.badgeNumber;   
 var badgeXml = notifications.BadgeUpdateManager.getTemplateContent(badgeType);   
 var badgeAttributes = badgeXml.getElementsByTagName("badge");    
 badgeAttributes[0].setAttribute("value", "7");    
 var badgeNotification = new notifications.BadgeNotification(badgeXml);
 notifications.BadgeUpdateManager.createBadgeUpdaterForApplication().update(badgeNotification);

更新

嗨,上面的代码在 windows8 桌面上为我工作,但是当我在模拟器中运行它时,它没有显示徽章文本。任何人都可以帮我解决这个问题

4

1 回答 1

0

不幸的是,所有通知 API(toast、tile、badge 和推送通知)在 Windows 8 模拟器中都不起作用。要测试和调试,请使用“本地机器”作为目标。

于 2013-05-08T14:26:53.017 回答