locked
Can't update SecondaryTile RRS feed

  • Question

  • Hi,

    I have created a blank app with 2 buttons, the first one create a tile which works fine and the second button updates this tile previously created. My problem is that I don t see the tile updated and no exceptions are thrown.

    I copied and pasted the code from http://msdn.microsoft.com/en-us/library/windows/apps/hh868226.aspx

    Here is the code of my second button:

            private async void testBT_Tapped2(object sender, TappedRoutedEventArgs e)
            {
                if (SecondaryTile.Exists("MyId"))
                {
                    XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideBlockAndText01);
                    XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
                    tileTextAttributes[0].InnerText = "This text was delivered through a notification";
    
                    XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareBlock);
                    XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
                    squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode("This text was delivered through a notification"));
    
                    IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
                    tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
    
                    TileNotification tileNotification = new TileNotification(tileXml);
                    TileUpdater secondaryTileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile("MyId");
                    secondaryTileUpdater.Update(tileNotification);
    
                }
            }

    I have used the same id to create the tile which is hardcoded as "MyId"

    I'm expecting to see the text displayed on the secondary tile but nothing. Anyone knows what I'm doing wrong?

    Thanks,

    Sebastien



    • Edited by Sebaust Tuesday, September 3, 2013 12:05 AM
    Tuesday, September 3, 2013 12:01 AM

Answers

  • I just found the issue it fact it works when testing on the device. It looks like tile notifications doesn't work on the emulator and I did most of my tests with it.

    I m using Windows 8.0

    Thanks

    • Marked as answer by Sebaust Sunday, September 8, 2013 11:13 PM
    Sunday, September 8, 2013 11:12 PM

All replies

  • From a quick look, code seems ok.  My question for you is:  if you step through this in the debugger, can you capture a reference to the secondary tile using its id ("MyId") and verify that the reference is good?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, September 3, 2013 12:47 PM
    Moderator
  • Hi Matt, thanks for your answer.

    Yes the tile is existing, I added the following lines in the if statement:

                if (SecondaryTile.Exists("MyInuqId"))
                {
                    IReadOnlyList<SecondaryTile> tiles = await SecondaryTile.FindAllForPackageAsync();
                    SecondaryTile myTile = tiles.FirstOrDefault();
    myTile is not null and corresponds correctly to the one previously created.




    • Edited by Sebaust Wednesday, September 4, 2013 4:06 AM
    Wednesday, September 4, 2013 4:05 AM
  • No one has an idea?
    Thursday, September 5, 2013 10:58 PM
  • Hi, Sebastien. What version of OS do you use?
    Saturday, September 7, 2013 12:50 AM
  • I just found the issue it fact it works when testing on the device. It looks like tile notifications doesn't work on the emulator and I did most of my tests with it.

    I m using Windows 8.0

    Thanks

    • Marked as answer by Sebaust Sunday, September 8, 2013 11:13 PM
    Sunday, September 8, 2013 11:12 PM