如何使用外部文件来处理 FirefoxOS 中的推送通知?

How to use external file to handle push notifications in FirefoxOS?

我正在尝试在我的 FirefoxOS 应用程序上运行推送通知。虽然它在应用程序打开时按预期工作,但当应用程序关闭时它不再工作。我以为是应用程序正在尝试执行整个应用程序而不是仅执行处理程序,所以我正在尝试使用 manifest.webapp.

上的消息部分
"messages": [
    { "push": "/push/push.html" },
    { "push-register" : "index.html" },
    { "notification": "index.html" }
],

我在 /push/push.html 上的代码是:

<script>

navigator.mozSetMessageHandler('push', function () {
  c = new Notification( 'testing 4' );
});
</script>

但是当推送消息到达设备时,似乎没有加载文件。对我来说,这似乎不是路径问题,因为我尝试了一切(启动路径是/index.html,我试过将push.html移动到根目录并把/push.html).

有线索吗?

好吧,经过几个小时的尝试和大量研究,似乎无法在另一个页面中进行推送。

Remember: when a user selects an app, the lauch_path is displayed. There’s a bug right now that restricts push notifications to the page that calls register(). Right now, what’s under “messages” doesn’t matter if it’s not the same as the page that calls register(). Keep your eye on that bug if you want to know when it’s fixed. For now, it’s probably a good idea to keep your app to one page and use dynamic formatting to present info back to the user.

Firefox OS v1.1 only allows the page that registers for Push Notifications to recieve them, so you cannot have / call navigator.push.register() and have /push.html be the receiver that uses navigator.mozSetMessageHandler().

有关错误的更多信息: https://bugzilla.mozilla.org/show_bug.cgi?id=800431[^] https://bugzilla.mozilla.org/show_bug.cgi?id=897112[^]