SlideShare a Scribd company logo
Bringing the Open Web & APIs to
mobile devices with Firefox OS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Using HTML5, CSS and
JavaScript together with a
number of APIs to build
apps and customize the UI.
Firefox OS
Open Web Apps
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Develop Web App using
HTML5, CSS, & Javascript1.
Create an app manifest file2.
Publish/install the app3.
{
"version": "1.0",
"name": "MozillaBall",
"description": "Exciting Open Web development action!",
"icons": {
"16": "/img/icon-16.png",
"48": "/img/icon-48.png",
"128": "/img/icon-128.png"
},
"developer": {
"name": "Mozilla Labs",
"url": "http://mozillalabs.com"
},
"installs_allowed_from": ["*"],
"appcache_path": "/cache.manifest",
"locales": {
"es": {
"description": "¡Acción abierta emocionante del desarrollo del Web!",
"developer": {
"url": "http://es.mozillalabs.com/"
}
},
"it": {
"description": "Azione aperta emozionante di sviluppo di
fotoricettore!",
"developer": {
"url": "http://it.mozillalabs.com/"
}
}
},
"default_locale": "en"
}
MANIFEST CHECKER
http://appmanifest.org/
Serve with Content-type/MIME type:
application/x-web-app-manifest+json
https://marketplace.firefox.com/
https://marketplace.firefox.com/developers/
Packaged vs. Hosted Apps
https://developer.mozilla.org/docs/Apps/
For_Web_developers
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
WebAPIs
https://wiki.mozilla.org/WebAPI
Security Levels
Web Content
Regular web content
Installed Web App
A regular web app
Privileged Web App
More access, more responsibility
Certified Web App
Device-critical applications
https://wiki.mozilla.org/
WebAPI#Planned_for_initial_release_of_B2G_.
28aka_Basecamp.29
"permissions": {
"contacts": {
"description": "Required for autocompletion in the share screen",
"access": "readcreate"
},
"alarms": {
"description": "Required to schedule notifications"
}
}
PERMISSIONS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Vibration API (W3C)
Screen Orientation
Geolocation API
Mouse Lock API (W3C)
Open WebApps
Network Information API (W3C)
Battery Status API (W3C)
Alarm API
Web Activities
Push Notifications API
WebFM API
WebPayment
IndexedDB (W3C)
Ambient light sensor
Proximity sensor
Notification
REGULAR APIS
BATTERY STATUS
API
var battery = navigator.battery;
if (battery) {
var batteryLevel = Math.round(battery.level * 100) + "%",
charging = (battery.charging)? "" : "not ",
chargingTime = parseInt(battery.chargingTime / 60, 10,
dischargingTime = parseInt(battery.dischargingTime / 60, 10);
// Set events
battery.addEventListener("levelchange", setStatus, false);
battery.addEventListener("chargingchange", setStatus, false);
battery.addEventListener("chargingtimechange", setStatus, false);
battery.addEventListener("dischargingtimechange", setStatus, false);
}
NOTIFICATION
var notification = navigator.mozNotification;
notification.createNotification(
"See this",
"This is a notification",
iconURL
);
SCREEN
ORIENTATION API
// Portrait mode:
screen.mozLockOrientation("portrait");
/*
Possible values:
"landscape"
"portrait"
"landscape-primary"
"landscape-secondary"
"portrait-primary"
"portrait-secondary"
*/
VIBRATION API
// Vibrate for one second
navigator.vibrate(1000);
// Vibration pattern [vibrationTime, pause,…]
navigator.vibrate([200, 100, 200, 100]);
// Vibrate for 5 seconds
navigator.vibrate(5000);
// Turn off vibration
navigator.vibrate(0);
WEB PAYMENTS
var pay = navigator.mozPay(paymentToken);
pay.onsuccess = function (event) {
// Weee! Money!
};
NETWORK
INFORMATION API
var connection = window.navigator.mozConnection,
online = connection.bandwidth > 0,
metered = connection.metered;
DEVICEPROXIMITY
window.addEventListener("deviceproximity", function (event) {
// Current device proximity, in centimeters
console.log(event.value);
// The maximum sensing distance the sensor is
// able to report, in centimeters
console.log(event.max);
// The minimum sensing distance the sensor is
// able to report, in centimeters
console.log(event.min);
});
AMBIENT LIGHT
EVENTS
window.addEventListener("devicelight", function (event) {
// The level of the ambient light in lux
console.log(event.value);
});
window.addEventListener("devicelight", function (event) {
// The lux values for "dim" typically begin below 50,
// and the values for "bright" begin above 10000
console.log(event.value);
});
Device Storage API
Browser API
TCP Socket API
Contacts API
systemXHR
PRIVILEGED APIS
DEVICE STORAGE
API
var deviceStorage = navigator.getDeviceStorage("videos");
// "external", "shared", or "default".
deviceStorage.type;
// Add a file - returns DOMRequest with file name
deviceStorage.add(blob);
// Same as .add, with provided name
deviceStorage.addNamed(blob, name);
// Returns DOMRequest/non-editable File object
deviceStorage.get(name);
// Returns editable FileHandle object
deviceStorage.getEditable(name);
// Returns DOMRequest with success or failure
deviceStorage.delete(name);
// Enumerates files
deviceStorage.enumerate([directory]);
// Enumerates files as FileHandles
deviceStorage.enumerateEditable([directory]);
var storage = navigator.getDeviceStorage("videos"),
cursor = storage.enumerate();
cursor.onerror = function() {
console.error("Error in DeviceStorage.enumerate()", cursor.error.name);
};
cursor.onsuccess = function() {
if (!cursor.result)
return;
var file = cursor.result;
// If this isn't a video, skip it
if (file.type.substring(0, 6) !== "video/") {
cursor.continue();
return;
}
// If it isn't playable, skip it
var testplayer = document.createElement("video");
if (!testplayer.canPlayType(file.type)) {
cursor.continue();
return;
}
};
CONTACTS API
var contact = new mozContact();
contact.init({name: "Tom"});
var request = navigator.mozContacts.save(contact);
request.onsuccess = function() {
console.log("Success");
};
request.onerror = function() {
console.log("Error")
};
WebTelephony
WebSMS
Idle API
Settings API
Power Management API
Mobile Connection API
WiFi Information API
WebBluetooth
Permissions API
Network Stats API
Camera API
Time/Clock API
Attention screen
Voicemail
CERTIFIED APIS
WEBTELEPHONY
// Telephony object
var tel = navigator.mozTelephony;
// Check if the phone is muted (read/write property)
console.log(tel.muted);
// Check if the speaker is enabled (read/write property)
console.log(tel.speakerEnabled);
// Place a call
var cal = tel.dial(“123456789”);
// Receiving a call
tel.onincoming = function (event) {
var incomingCall = event.call;
// Get the number of the incoming call
console.log(incomingCall.number);
// Answer the call
incomingCall.answer();
};
// Disconnect a call
call.hangUp();
// Iterating over calls, and taking action depending on their
changed status
tel.oncallschanged = function (event) {
tel.calls.forEach(function (call) {
// Log the state of each call
console.log(call.state);
});
};
WEBSMS
// SMS object
var sms = navigator.mozSMS;
// Send a message
sms.send("123456789", "Hello world!");
// Recieve a message
sms.onreceived = function (event) {
// Read message
console.log(event.message);
};
WEB ACTIVITIES
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
{
"activities": {
"share": {
"filters": {
"type": ["image/png", "image/gif"]
}
"href": "sharing.html",
"disposition": "window"
}
}
}
var activity = new MozActivity({
name: "view",
data: {
type: "image/png",
url: ...
}
});
activity.onsuccess = function () {
console.log("Showing the image!");
};
activity.onerror = function () {
console.log("Can't view the image!");
};
var register = navigator.mozRegisterActivityHandler({
name: "view",
disposition: "inline",
filters: {
type: "image/png"
}
});
register.onerror = function () {
console.log("Failed to register activity");
}
navigator.mozSetMessageHandler("activity", function (a) {
var img = getImageObject();
img.src = a.source.url;
// Call a.postResult() or a.postError() if
// the activity should return a value
});
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Future APIs
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Resource lock API
UDP Datagram Socket API
Peer to Peer API
WebNFC
WebUSB
HTTP-cache API
Calendar API
Spellcheck API
LogAPI
Keyboard/IME API
WebRTC
FileHandle API
Sync API
Web Apps from Mozilla
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Dialer
Contacts
Settings
SMS
Web browser
Gallery
Video Player
Music Player
E-mail (POP, IMAP)
Calendar
Alarm Clock
Camera
Notes
First Run Experience
Notifications
Home Screen
Mozilla Marketplace
System Updater
Localization Support
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
https://hacks.mozilla.org/2013/01/hacking-gaia-for-firefox-
os-part-1/
Get started
https://addons.mozilla.org/firefox/addon/firefox-os-
simulator/
FIREFOX OS
BOILERPLATE APP
https://github.com/robnyman/Firefox-OS-Boilerplate-App
WebRTC
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
var video = document.querySelector('video');
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL ||
window.msURL;
// Call the getUserMedia method with our callback functions
if (navigator.getUserMedia) {
navigator.getUserMedia({video: true}, successCallback, errorCallback);
} else {
console.log('Native web camera streaming (getUserMedia) not supported
in this browser.');
// Display a friendly "sorry" message to the user
}
function successCallback(stream) {
// Set the source of the video element with the stream from the camera
if (video.mozSrcObject !== undefined) {
video.mozSrcObject = stream;
} else {
video.src = (window.URL && window.URL.createObjectURL(stream)) ||
stream;
}
video.play();
}
Getting help
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
https://lists.mozilla.org/listinfo/dev-webapps
irc://irc.mozilla.org/
#openwebapps
Trying things out
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Robert Nyman
robertnyman.com
robert@mozilla.com
Mozilla
@robertnyman

More Related Content

PDF
Firefox OS workshop, Colombia
PDF
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
PDF
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
PDF
WebAPIs & WebRTC - Spotify/sthlm.js
PDF
A Gentle Introduction to Event Loops
PDF
The Open Web and what it means
ZIP
WebLogic Administration und Deployment mit WLST
PDF
Unity and WebSockets
Firefox OS workshop, Colombia
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
WebAPIs & WebRTC - Spotify/sthlm.js
A Gentle Introduction to Event Loops
The Open Web and what it means
WebLogic Administration und Deployment mit WLST
Unity and WebSockets

What's hot (20)

PDF
soft-shake.ch - Hands on Node.js
PDF
Asynchronous Programming FTW! 2 (with AnyEvent)
PDF
Websockets talk at Rubyconf Uruguay 2010
PDF
Perkenalan ReasonML
PDF
Electron Firenze 2020: Linux, Windows o MacOS?
KEY
Playing With Fire - An Introduction to Node.js
PPTX
PPTX
JavaScript on the Desktop
PDF
Asynchronous programming patterns in Perl
PDF
Introduction to ReasonML
PPTX
ES6 is Nigh
PPTX
Perl: Coro asynchronous
PDF
Web Crawling with NodeJS
PDF
Persisting Data on SQLite using Room
PDF
Boom! Promises/A+ Was Born
PDF
Hello watchOS2
PDF
Any event intro
PDF
WebSockets, Unity3D, and Clojure
PDF
Ansible - Swiss Army Knife Orchestration
PDF
JavaScript Promise
soft-shake.ch - Hands on Node.js
Asynchronous Programming FTW! 2 (with AnyEvent)
Websockets talk at Rubyconf Uruguay 2010
Perkenalan ReasonML
Electron Firenze 2020: Linux, Windows o MacOS?
Playing With Fire - An Introduction to Node.js
JavaScript on the Desktop
Asynchronous programming patterns in Perl
Introduction to ReasonML
ES6 is Nigh
Perl: Coro asynchronous
Web Crawling with NodeJS
Persisting Data on SQLite using Room
Boom! Promises/A+ Was Born
Hello watchOS2
Any event intro
WebSockets, Unity3D, and Clojure
Ansible - Swiss Army Knife Orchestration
JavaScript Promise
Ad

Similar to Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet (20)

PDF
Firefox OS workshop, JSFoo, India
PDF
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
PDF
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
PDF
Firefox OS learnings & visions, WebAPIs - budapest.mobile
PDF
Bringing the Open Web & APIs to 
mobile devices with Firefox OS, JSFoo, India
PDF
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - GOTO confer...
PDF
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
PDF
Mozilla, Firefox OS and the Open Web
PDF
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
PDF
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
PDF
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
PDF
WebRTC & Firefox OS - presentation at Google
PDF
Web APIs & Apps - Mozilla
PDF
Fixing the mobile web - Internet World Romania
PDF
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
PDF
Firefox OS - A (mobile) Web Developers dream - DWX14
PDF
APIs, now and in the future
PDF
Firefox OS
PDF
HTML for the Mobile Web, Firefox OS
PDF
(Christian heilman) firefox
Firefox OS workshop, JSFoo, India
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS learnings & visions, WebAPIs - budapest.mobile
Bringing the Open Web & APIs to 
mobile devices with Firefox OS, JSFoo, India
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - GOTO confer...
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Mozilla, Firefox OS and the Open Web
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
WebRTC & Firefox OS - presentation at Google
Web APIs & Apps - Mozilla
Fixing the mobile web - Internet World Romania
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS - A (mobile) Web Developers dream - DWX14
APIs, now and in the future
Firefox OS
HTML for the Mobile Web, Firefox OS
(Christian heilman) firefox
Ad

More from Robert Nyman (20)

PDF
Have you tried listening?
PDF
Building for Your Next Billion - Google I/O 2017
PDF
Introduction to Google Daydream
PDF
Predictability for the Web
PDF
The Future of Progressive Web Apps - View Source conference, Berlin 2016
PDF
The Future of the Web - Cold Front conference 2016
PDF
The Future of Progressive Web Apps - Google for Indonesia
PDF
Google tech & products
PDF
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
PDF
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
PDF
The web - What it has, what it lacks and where it must go - keynote at Riga D...
PDF
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
PDF
The web - What it has, what it lacks and where it must go - Istanbul
PDF
The web - What it has, what it lacks and where it must go
PDF
Google, the future and possibilities
PDF
Developer Relations in the Nordics
PDF
What is Developer Relations?
PDF
Android TV Introduction - Stockholm Android TV meetup
PDF
New improvements for web developers - frontend.fi, Helsinki
PDF
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki
Have you tried listening?
Building for Your Next Billion - Google I/O 2017
Introduction to Google Daydream
Predictability for the Web
The Future of Progressive Web Apps - View Source conference, Berlin 2016
The Future of the Web - Cold Front conference 2016
The Future of Progressive Web Apps - Google for Indonesia
Google tech & products
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Istanbul
The web - What it has, what it lacks and where it must go
Google, the future and possibilities
Developer Relations in the Nordics
What is Developer Relations?
Android TV Introduction - Stockholm Android TV meetup
New improvements for web developers - frontend.fi, Helsinki
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Electronic commerce courselecture one. Pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Machine learning based COVID-19 study performance prediction
Programs and apps: productivity, graphics, security and other tools
Electronic commerce courselecture one. Pdf
sap open course for s4hana steps from ECC to s4
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Machine learning based COVID-19 study performance prediction

Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet