Reputation: 1095
I have an instant messaging application almost complete the only thing I'm missing are firefox notifications for you. As is the API?
Upvotes: 3
Views: 3025
Reputation: 666
For server based push notifications see Simple Push that includes implementation examples. This is available in Firefox OS (/Boot2Gecko) 1.1. but not in 1.0 (which is on all currently released devices). Please also note, that you'll need a real device and it won't work in the emulator.
Simple Push itself is not difficult to implement given the above link. Nevertheless there a couple of things you need to take care about:
launch_path
from the manifest (this means you'll have to put all the logic in one page) due to a bugIt is possible to build similar functionality on Boot2Gecko 1.0 using MozAlarmsManager.
Upvotes: 1
Reputation: 643
It's not clear if you're after Notifications API or Push Notifications API, so I'll talk about both.
First, the Notification "API" (I'm not sure if it's been renamed to be an API, and I'm afraid it's just known as "Notification" by now). You can use mozNotification
to create new notification objects and use show
to display them:
var notification = navigator.mozNotification;
var n = notification.createNotification("Title", "Body", "optional_icon.png");
n.show();
On both links, you can get a better understanding what can be done with this.
Be sure you ask for permission to use this (add this to your manifest.webapp
):
"permissions": {
"desktop-notification":{}
}
To make it easier, I've made a demo app. That a look at how it works, and the changes I've made.
Warning: this is different from Web Notifications.
The Push API is already listed on Mozilla Wiki, but it's work in progress AFAIK. You can follow the news on this specific API on Mozilla Wiki, on github (server side stuff) and on the Gecko implementation bug.
There's another API, the SimplePush API, that seems to be working by now. Unfortunately, I don't know much about it. But at least the documentation seems pretty good.
Unfortunately again, I don't know how those APIs relate to W3C's Push API. I'm afraid the Push API is somewhat related to the standard, although I'm not sure of that. I wouldn't rely on any other documentation besides Mozilla's, in the case of these APIs.
Upvotes: 9