简体   繁体   English

如何在JS / HTML / CSS中每分钟更新Windows Store应用程序的实时磁贴?

[英]How to update visually a live tile every minute of a Windows Store App in JS/HTML/CSS?

I would like the live tile of my app to be updated everytime the user opens the Start screen as its live tile's feature is "only" visual (doesn't need to be on lockscreen or perform specific logic in the background for example) 我希望每次用户打开“开始”屏幕时都会更新我的应用程序的实时图块,因为其实时图块的功能是“仅”可视(例如,不需要在锁定屏幕上或在后台执行特定逻辑)

On the windows Store you can find "watches" app which will show you the time on the start screen via their app live tile usually with a granularity of every minute not more. 在Windows商店,你可以找到“手表”应用程序,它将通过他们的应用程序实时图块显示在开始屏幕上的时间,通常具有每分钟的粒度而不是更多。 This would be perfect for me. 这对我来说是完美的。

Watch in a live tile. 观看现场瓷砖。 http://img812.imageshack.us/img812/8143/watchtile.png http://img812.imageshack.us/img812/8143/watchtile.png

Those apps seems to have then a much more precise time interval than those famous 15 minutes, and they do run as a background task (those apps ask for the permission to). 这些应用程序似乎比那些着名的15分钟具有更精确的时间间隔,并且它们确实作为后台任务运行(这些应用程序要求获得许可)。

So what does actually happen every 15 minutes? 那么每15分钟实际发生什么呢? How come those tiles are not constrained to this 15 minutes interval? 为什么这些瓷砖不会受到这15分钟的限制? I heard they might use a notifications queue, but they still need to be updated on 1 minute basis... 我听说他们可能会使用通知队列,但他们仍然需要在1分钟内更新...

Thanks a lot for help! 非常感谢您的帮助!

You can use TileUpdater.addToSchedule to schedule up to 4096 notifications . 您可以使用TileUpdater.addToSchedule来安排最多4096个通知 So, I imagine one approach is: 所以,我想一个方法是:

  1. Set up a maintenance task to run at some interval (don't need to be on the lock screen for this). 设置维护任务以在某个时间间隔运行(不需要在锁定屏幕上)。
  2. When the task runs: 任务运行时:

    2a. 2A。 Clear out your notification queue. 清除通知队列。

    2b. 2B。 Schedule a bunch of notifications, one for now + 1 minute, one for now + 2 minutes, etc (register fewer than 4096, and don't register more than you really need). 安排一堆通知,一个现在+ 1分钟,一个现在+ 2分钟等(注册少于4096,并且注册不超过你真正需要的)。

Your maintenance task could be scheduled to run daily, but you could schedule 2 days worth of notifications in case it doesn't get run in time. 您的维护任务可以安排为每天运行,但如果没有及时运行,您可以安排2天的通知。

The main downside with this is that if the user is on battery power for more than 2 days (or however far out you schedule them), your notifications will stop until they plug in and your maintenance task is allowed to run. 这样做的主要缺点是,如果用户使用的电池电量超过2天(或者您计划的时间太长),您的通知将会停止,直到它们插入并允许您的维护任务运行。

If you don't need an update every single minute, you could schedule them farther into the future (ie a week or more, if you did every 5 minutes). 如果您不需要每分钟更新一次,那么您可以将它们安排在更远的地方(例如,如果您每隔5分钟执行一周或更长时间)。

Notice the types of notifications found here . 请注意此处找到的通知类型。

The 15 minute limitation you mention is discussed under the periodic notifications found here . 您提到的15分钟限制将在此处的定期通知中讨论。

Local, scheduled and push notifications can probably all do what you require, although I'm less sure about the scheduled notifications since I think there is a limit on the number of these you can have queued up at one time. 本地,预定和推送通知可能都可以满足您的要求,虽然我对预定的通知不太确定,因为我认为您可以一次排队的数量有限制。

(I think - haven't tested this) A local notification can be used to send tile updates from a background task, but this has the limitation that your app needs to be running to have this work. (我认为 - 尚未对此进行测试)本地通知可用于从后台任务发送磁贴更新,但这具有您的应用程序需要运行才能使其工作的限制。

Push notifications come from a cloud service and can happen while your app is not running. 推送通知来自云服务,可能会在您的应用未运行时发生。 Unfortunately this requires a cloud service. 不幸的是,这需要云服务。

My team member here at Microsoft Michael Palermo (blog here ) has a similar app called Tile of Time 我的团队在微软迈克尔·巴勒莫(博客这里成员在这里 )有一个名为类似的应用程序时间的瓷砖

It seems like a very simple app, but the trick here as I understood it from him was to schedule a background task out for the next fifteen minutes for every one of the updates and ensure there are no duplicates. 它看起来像一个非常简单的应用程序,但是我从他那里理解的诀窍就是在接下来的十五分钟内为每一个更新安排一个后台任务,并确保没有重复。 It seems like a lot, but that's to workaround the time constraints provided for background tasks. 看起来很多,但这是解决为后台任务提供的时间限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何每30分钟更新动态图块(Win 8应用程序) - How to update live tile (win 8 app) every 30min Windows 8商店应用程序:如何使应用程序实时图块颜色(和文本)不断变化? - Windows 8 store app: how to have the app live tile change constantly of colour (and text)? 在Windows Store JS / HTML / CSS应用程序中使用Phonegap / Cordova插件? - Use Phonegap/Cordova plugin in Windows Store JS/HTML/CSS app? Moment.js:如何更新每分钟的时间? - Moment.js: how to update the time every minute? 如何在Polymer 2中的moment-js组件中每分钟更新时间? - How to update time every minute in moment-js component in Polymer 2? 如何填充Windows 8.1活动图块? - How to Populate a Windows 8.1 live tile? 每当我在Vim中保存其“源文件”时,如何自动更新或压缩CSS,JS和HTML文件? - How to automatically update or compress a CSS, JS and HTML file every time I save its “source file” in Vim? 如何每分钟呈现页面幻影js - how to render page phantom js every minute 如何以编程方式卸载Windows Store App(JS) - How to uninstall Windows Store App programmatically (JS) 按当前时间戳每分钟更新 node.js express api - update node.js express api every minute by the current timestamp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM