为什么标识符二次瓷砖无效? [英] Why is identifier for secondary tile invalid?

查看:176
本文介绍了为什么标识符二次瓷砖无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图直接更新使用XML的Windows 8二次瓦。不过,我不断收到一个例外,对瓷砖的标识符我寄托无效。我甚至尝试直接从Windows拉动标识,替代后的回 CreateTileUpdaterForSecondaryTile ,但我仍然得到同样的异常。这里是我的代码:

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.



任何想法的问题是什么? foreach循环只是因为我的版本只有一个固定的二次瓦的执行一次。 (我也认识到, UpdateSecondarySectionTile 应采取tileId作为参数,并只更新每次调用一个块。这只是调试代码)

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.

推荐答案

在这个问题(提供的应用程序标识符无效)可以通过 CreateTileUpdaterForSecondaryTile 方法抛出的模拟器之外如果二次瓷砖被引用的例外最初寄托而在模拟器。要解决此问题,取消固定模拟器外的二次瓷砖和列宾它。

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.

正如问题作者指出的,瓦片更新的API(以及其他推送通知相关的API)不会在模拟器支持。在这种情况下,次级瓦钉扎是不持久的模拟器外

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.

这篇关于为什么标识符二次瓷砖无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆