You saw how to specify the background image of an application tile using push notification. There is, however, an alternative approach that lets you set the background image to a remote URI without using push notification, eliminating the need for a cloud service to issue tile notifications.
By using the ShellTileSchedule
class the phone can be directed to periodically download an image from a remote server.
To create a schedule for a tile update, create a new instance of the ShellTileSchedule
class and set the RemoteImageUri
property, as shown in the following example:
string url = "http://www.example.com/ImageName.png";
ShellTileSchedule schedule = new ShellTileSchedule
{
Interval = UpdateInterval.EveryHour,
MaxUpdateCount = 10,
Recurrence = UpdateRecurrence.Interval,
RemoteImageUri = new Uri(url),
StartTime = DateTime.Now
};
schedule.Start();
The following is a list of ShellTileSchedule
properties that affect the download frequency:
Interval—This property specifies the download frequency rate and is of type Microsoft.Phone.Shell.UpdateInterval
. UpdateInterval
is an enumeration with the following values:
EveryHour
EveryWeek
EveryMonth
If the shortest frequency, EveryHour
, does not offer a short enough interval, push notification or a background agent should be considered instead.
MaxUpdateCount—This property defines the number of times the schedule runs. If this value is not set or set to a number less than 1, the schedule runs indefinitely. This value is ignored if Recurrence
is set to OneTime
.
Recurrence—This property specifies whether the image is to be fetched periodically, or if retrieval of the image is to occur only once. The available values are UpdateRecurrence.Interval
or UpdateRecurrence.OneTime
.
RemoteImageUri—This property is the fully qualified URI of the background image. It cannot point to a local image stored on the phone.
StartTime—This property specifies the duration from the initial ShellTileSchedule.Start
method call until the first time that the image is fetched. This property is used to delay the initial download of an image.
Caution
The same restrictions apply to images retrieved using a ShellTileSchedule
as those in tile notifications. In particular, image size must not exceed 80KB, and the download time must not exceed 1 minute. If the image size is too large, or the download takes too long, not only is the default image used for the tile, but the tile schedule is also removed. The only way to reinstate a schedule is to rerun the schedule generation code.
3.147.84.157