Reputation: 1618
I am trying to update a Windows 8 secondary tile directly using XML. However, I keep getting an exception that the identifier for the tile I pinned is invalid. I even tried pulling the identifier directly from Windows and then substituting that back into CreateTileUpdaterForSecondaryTile
, but I'm still getting the same exception. Here's my code:
public async static void UpdateSecondarySectionTile()
{
string tileXmlString = "<tile id='SecondaryTile-7-0'>"
+ "<visual>"
+ "<binding template='TileWideImage'>"
+ "<image id='1' src='" + imageSource + "' alt='alt text'/>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
// create a DOM
Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
tileDOM.LoadXml(tileXmlString);
System.Collections.Generic.IReadOnlyList<Windows.UI.StartScreen.SecondaryTile> tileList = await Windows.UI.StartScreen.SecondaryTile.FindAllAsync();
foreach (var tile in tileList)
{
string tileId = tile.TileId;
Windows.UI.Notifications.TileNotification tileUpdate = new Windows.UI.Notifications.TileNotification(tileDOM);
try
{
Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileUpdate);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("message: " + e.Message + ", inner exception: " + e.InnerException + " string: " + e.ToString());
}
}
}
The debug line is outputting:
//message: The application identifier provided is invalid.
, inner exception: string: System.Exception: The application identifier provided is invalid.
Any idea what the problem is? The foreach loop only executes once because there's only one pinned secondary tile on my build. (Also I realize that UpdateSecondarySectionTile
should take the tileId as a parameter and only update one tile per call; this is just debugging code.)
I find it interesting that it's complaining about the application identifier rather than the tile identifier. Also, I'm aware that tile updates sometimes do not work if you run them in the simulator, but I am encountering this issue even on my local machine.
Upvotes: 2
Views: 1176
Reputation: 14162
The exception referenced in the question ("The application identifier provided is invalid") can be thrown by the CreateTileUpdaterForSecondaryTile
method outside of the simulator if the secondary tile was initially pinned while in the simulator. To work around this issue, unpin the secondary tile and repin it outside of the simulator.
As noted by the question author, the tile update APIs (and other push notification related APIs) are not supported in the simulator. In this case, the secondary tile pinning was not persisted outside of the simulator.
Upvotes: 3