来自localhost的Windows 8磁贴通知



我正在为windows8开发一个简单的应用程序。在我的应用程序中,我希望开始磁贴显示我随应用程序附带的本地主机的图像。例如,我像wise一样将我的图像保存在/images/tile1.jpg上。我的xml代码是

<tile>
<visual>
<binding template="TileWideImage">
<image id="1" src ="http://localhost/images/tile1.jpg" />
</binding>
</visual>

其同样存在于/tile1.xml

我的default.js代码是

// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
"use strict";
WinJS.Binding.optimizeBindingReferences = true;
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
var notifications = Windows.UI.Notifications;
var recurrence = notifications.PeriodicUpdateRecurrence.halfHour;

var urls = [
new Windows.Foundation.Uri("http://localhost/tile1.xml"),
new Windows.Foundation.Uri("http://localhost/tile2.xml"),
new Windows.Foundation.Uri("http://localhost/tile3.xml"),
new Windows.Foundation.Uri("http://localhost/tile4.xml")
];

notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);
notifications.TileUpdateManager.createTileUpdaterForApplication().startPeriodicUpdateBatch(urls, recurrence);
} else {
// TODO: This application has been reactivated from suspension.
// Restore application state here.
}
args.setPromise(WinJS.UI.processAll());
}
};
app.oncheckpoint = function (args) {
// TODO: This application is about to be suspended. Save any state
// that needs to persist across suspensions here. You might use the
// WinJS.Application.sessionState object, which is automatically
// saved and restored across suspension. If you need to complete an
// asynchronous operation before your application is suspended, call
// args.setPromise().
};

app.start();
})();

我只是弄不清代码出了什么问题。请帮忙。

好吧,你不能。环回是不允许的,所以如果您使用本地主机服务,您的应用程序将无法通过认证。

你能用应用程序本身传递图像吗?或者,设置一个外部服务来托管您的图像和磁贴。你真的只需要像Windows Azure blob存储这样的东西,甚至不需要托管web服务。

最后,你要确保你总是包括一个正方形的瓷砖图像。用户始终拥有控制权,因此他们可能会选择不将您的应用程序显示为宽磁贴。

最新更新