When i try to update my UWP primary and / or secondary tile nothing will happen.
If i start my UWP app from Visual Studio 2017 the update function works fine and updates the tiles. But if i make a Windows Store app from VS 2017, the update function don't work any more.
This is my current update function:
using System;
using System.Diagnostics;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml.Controls;
namespace UpdateTile
{
public sealed class TileUpdate
{
// Function which is call by every background task to update the app tile
// and each app secondary tile
// The tile ID could be empty for update the primary tile
public static void ScheduleUpdate(String data, String tileID)
{
#region variables
TileUpdater tileUpdater = null;
#endregion
// Check the tile ID
if (tileID == "")
{
// If tile ID is empty then create a tile updater for the app tile
tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
}
else
{
tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID);
}
tileUpdater.EnableNotificationQueue(true);
tileUpdater.Clear();
tileUpdater.Update(new TileNotification(new TileXML().WriteXml(data)));
}
}
}
}
This is how i actually create the XML for the tiles:
using System;
using System.Diagnostics;
using SystemInformation;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Microsoft.Toolkit.Uwp.Notifications;
namespace UpdateTile
{
public sealed class TileXML
{
// Function to create a xml document for tiles
// returns a xml document
public XmlDocument WriteXml(String data)
{
#region variables
String[] result = { "" }; ;
SystemInfo sysinfo = new SystemInfo();
TileContent content = null;
String textCaption = "";
String textCaptionSubTle1 = "";
String textCaptionSubTle2 = "";
String textCaptionSubTle3 = "";
#endregion
Debug.WriteLine("Create xml document for tile");
if (String.IsNullOrEmpty(data))
{
// Set xml text for initial text file data
textCaption = "No data available";
}
else
{
// Split text file data by carriage return and new line
result = data.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
// check the result length to create an xml document text
if (result.Length == 1)
{
// Set xml text if no data file exists
textCaption = "No data available";
}
else
{
// Set xml text if data file is present
textCaption = sysinfo.Hostname;
textCaptionSubTle1 = result[3].Replace("Enterprise", "") + " v" + result[4];
textCaptionSubTle2 = "IP: " + sysinfo.IP_Address;
textCaptionSubTle3 = "Hotline: " + result[1];
}
}
// Create an adaptive tile content
content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
BackgroundImage = new TileBackgroundImage()
{
Source = "Assets/Backgroung.png",
HintOverlay = 60
},
Children =
{
new AdaptiveText()
{
Text = textCaption,
HintStyle = AdaptiveTextStyle.Caption
},
new AdaptiveText()
{
Text = textCaptionSubTle1,
HintStyle = AdaptiveTextStyle.CaptionSubtle
},
new AdaptiveText()
{
Text = textCaptionSubTle2,
HintStyle = AdaptiveTextStyle.CaptionSubtle
},
new AdaptiveText()
{
Text = textCaptionSubTle3,
HintStyle = AdaptiveTextStyle.CaptionSubtle
}
}
}
}
}
};
// return the xml domument from adaptive tile content
return content.GetXml();
}
}
}
I have also tried to use RAW XML to update the tiles, but nothing will work. Does anyone have an idea why the tile update works with VS 2017, but not as a Windows Store app?
The Publisher-Certificate has imported as a root certificate.
Information about my System: OS: Windows 10 v1703 --> Version: 10.0.15063.540
The Problem has been solved by myself.
When i create the XML for the live tile, i set a background image:
When i comment this out, and make a new Windows Store App, the live update will work again.
Maybe the image has not the correct dimension