javascript - 我的 Windows 8 应用程序中的磁贴上的徽章

标签 javascript html windows-8

我想在 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 桌面上适用于我,但是当我在模拟器中运行该代码时,它没有显示徽章文本。任何人都可以帮助我解决这个问题

最佳答案

遗憾的是,所有通知 API(toast、磁贴、徽章和推送通知)都无法在 Windows 8 模拟器中运行。要测试和调试,请使用“本地计算机”作为目标。

关于javascript - 我的 Windows 8 应用程序中的磁贴上的徽章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16437631/

相关文章:

javascript - 提供适合用户连接的视频 Assets ?

javascript - 如何在 AngularJS 中使用 ng-repeat 动态生成 ng-model ="my_{{$index}}"?

javascript - 当某些字段为空时阻止表单提交

javascript - 确定元素是否包裹在 float 元素周围

javascript - 将数据以随机形式数据存入数据库

javascript - jQuery .text() 返回空字符串和 .html() 使用任何源返回 "undefined"

javascript - 在 HTML Table 中将元素从一个类获取到另一类

.net - 使用 Inno Setup 在 Windows 8 上安装 .Net 3.5

windows-8 - GestureRecognizer 中的触摸点数量

windows-8 - 0x800a1391 - JavaScript 运行时错误 : 'WinJS' is undefined