Follow the slides
Contact me!
Today we will learn how to use them,
but as well how to define them and offer our services to other apps
How we can use notifications in Firefox OS
Tips and tricks (some of them proper hacks)
Push notifications for the win!
I mean, for the WEB!
Leverage some work to other apps!
Use them to execute tasks that other apps know how to do better than you
verb
filter (optional)
parameters (optional)
BOOM!
Let's take a look to an example application
... something weird in this notifications ...
notification createNotification(
in DOMString title,
in DOMString description,
in DOMString iconURL Optional
);
"permissions": {
"desktop-notification":{}
}
notification.show();
notification.onclick = function () { // do something cool };
notification.onclose = function () { // do something cooler };
window.navigator.mozSetMessageHandler('notification',
function onNotification(notification) {
...
});
});
Ready for version 1.1
But we can start playing with them!
First draft available: https://developer.mozilla.org/en-US/docs/WebAPI/Simple_Push
Named like that because:
It's Simple
It does Push
... and it's and API
Register to receive notifications
var req = navigator.push.register();
req.onsuccess = function(e) {
var endpoint = req.result;
console.log("New endpoint: " + endpoint );
}
req.onerror = function(e) {
console.log("Error getting a new endpoint: " + JSON.stringify(e));
}
Listen to system messages
window.navigator.mozSetMessageHandler('push', function(e) {
console.log('My endpoint is ' + e.pushEndpoint);
console.log('My new version is ' + e.version);
});
You will require some permissions and system message definitions in your manifest
"messages": [
{ "push": "/index.html" }
],
"permissions": {
"push": {}
}
Folow me: @mepartoconmigo
Get the slides
Get the examples
https://github.com/arcturus/firefox-os-webactivities