Search code examples
javascriptwindows-8windows-store-appsmicrosoft-metro

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. This would be perfect for me.

Watch in a live tile.

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).

So what does actually happen every 15 minutes? How come those tiles are not constrained to this 15 minutes interval? I heard they might use a notifications queue, but they still need to be updated on 1 minute basis...

Thanks a lot for help!


Solution

  • You can use TileUpdater.addToSchedule to schedule up to 4096 notifications. 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. Clear out your notification queue.

      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).

    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.

    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.

    If you don't need an update every single minute, you could schedule them farther into the future (i.e. a week or more, if you did every 5 minutes).