Your SlideShare is downloading. ×
0
Firefox OS, the Open Web & WebAPIs

@robertnyman
Mozilla is a
global nonprofit dedicated
to putting you
in control of
your online
experience and
shaping the
future of the
W...
Firefox OS

Using HTML5, CSS and
JavaScript together with a
number of APIs to build
apps and customize the UI.
Foxconn
Foxconn
Open Web Apps
HTML5 + manifest file (JSON)
{
"version": "1",
"name": "Firefox OS Boilerplate App",
"launch_path": "/index.html",
"description": "Boilerplate Firefox ...
Packaged & hosted apps
WebAPIs
Security Levels
Web Content

Certified Web App

Regular web content

Device-critical applications

Installed Web App
A regular web app
Priv...
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"
},...
PERMISSIONS
Vibration API (W3C)

Web Activities

Screen Orientation

Push Notifications API

Geolocation API

WebFM API

Mouse Lock API...
BATTERY STATUS
API
var battery = navigator.battery;
if (battery) {
var batteryLevel = Math.round(battery.level * 100) + "%",
charging = (batt...
NOTIFICATION
var notification = navigator.mozNotification;
notification.createNotification(
"See this",
"This is a notification",
iconU...
SCREEN
ORIENTATION API
// Portrait mode:
screen.mozLockOrientation("portrait");
/*
Possible values:
"landscape"
"portrait"
"landscape-primary"
"l...
VIBRATION API
// Vibrate for one second
navigator.vibrate(1000);
// Vibration pattern [vibrationTime, pause,…]
navigator.vibrate([200, 1...
WEB PAYMENTS
var pay = navigator.mozPay(paymentToken);
pay.onsuccess = function (event) {
// Weee! Money!
};
mozmarket.receipts.Prompter({
storeURL: "https://marketplace.mozilla.org/app/myapp",
supportHTML: '<a href="mailto:me@exam...
DEVICEPROXIMITY
window.addEventListener("deviceproximity", function (event) {
// Current device proximity, in centimeters
console.log(even...
AMBIENT LIGHT
EVENTS
window.addEventListener("devicelight", function (event) {
// The lux values for "dim" typically begin below 50,
// and the...
PAGE VISIBILITY
document.addEventListener("visibilitychange", function () {
if (document.hidden) {
console.log("App is hidden");
}
else {
...
Device Storage API
Browser API
TCP Socket API
Contacts API
systemXHR

PRIVILEGED APIS
DEVICE STORAGE
API
var deviceStorage = navigator.getDeviceStorage("videos");
var storage = navigator.getDeviceStorage("videos"),
cursor = storage.enumerate();
cursor.onerror = function() {
console.er...
WEB ACTIVITIES
Interacting with the camera
var activity = new MozActivity({
name: "view",
data: {
type: "image/png",
url: ...
}
});
activity.onsuccess = function () ...
{
"activities": {
"share": {
"filters": {
"type": ["image/png", "image/gif"]
}
"href": "sharing.html",
"disposition": "win...
Future APIs
Resource lock API

Spellcheck API

UDP Datagram Socket API

LogAPI

Peer to Peer API

Keyboard/IME API

WebNFC

WebRTC

We...
Web Apps from Mozilla
Dialer

Alarm Clock

Contacts

Camera

Settings

Notes

SMS

First Run Experience

Web browser

Notifications

Gallery

Hom...
Web Components & Mozilla Brick
http://mozilla.github.io/brick/
<x-flipbox>
<div>I'm the front face.</div>
<div>And I'm the back face.</div>
</x-flipbox>
// assume that toggleButton and flipBox are already
// defined as their respective DOM elements
toggleButton.addEventListe...
appbar
calendar
datepicker
deck
flipbox
iconbutton
layout

slidebox
slider
tabbar
toggle
togglegroup
tooltip
Get started
https://addons.mozilla.org/firefox/addon/firefox-ossimulator/
FIREFOX OS
BOILERPLATE APP

https://github.com/robnyman/Firefox-OS-Boilerplate-App
APP MANAGER
https://marketplace.firefox.com/
https://marketplace.firefox.com/developers/
Trying things out
Go have some fun!
Robert Nyman
robertnyman.com
robert@mozilla.com
Mozilla

@robertnyman
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Upcoming SlideShare
Loading in...5
×

Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco

2,192

Published on

Published in: Technology

Transcript of "Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco"

  1. 1. Firefox OS, the Open Web & WebAPIs @robertnyman
  2. 2. Mozilla is a global nonprofit dedicated to putting you in control of your online experience and shaping the future of the Web for the public good
  3. 3. Firefox OS Using HTML5, CSS and JavaScript together with a number of APIs to build apps and customize the UI.
  4. 4. Foxconn
  5. 5. Foxconn
  6. 6. Open Web Apps
  7. 7. HTML5 + manifest file (JSON)
  8. 8. { "version": "1", "name": "Firefox OS Boilerplate App", "launch_path": "/index.html", "description": "Boilerplate Firefox OS app", "icons": { "16": "/images/logo16.png", "32": "/images/logo32.png", "48": "/images/logo48.png", "64": "/images/logo64.png", "128": "/images/logo128.png" }, "developer": { "name": "Robert Nyman", "url": "http://robertnyman.com" }, "installs_allowed_from": ["*"], "default_locale": "en" }
  9. 9. Packaged & hosted apps
  10. 10. WebAPIs
  11. 11. Security Levels
  12. 12. Web Content Certified Web App Regular web content Device-critical applications Installed Web App A regular web app Privileged Web App More access, more responsibility
  13. 13. https://wiki.mozilla.org/ WebAPI#Planned_for_initial_release_of_B2G_.28aka_Basecamp.29
  14. 14. "permissions": { "contacts": { "description": "Required for autocompletion in the share screen", "access": "readcreate" }, "alarms": { "description": "Required to schedule notifications" } }
  15. 15. PERMISSIONS
  16. 16. Vibration API (W3C) Web Activities Screen Orientation Push Notifications API Geolocation API WebFM API Mouse Lock API (W3C) WebPayment Open WebApps IndexedDB (W3C) Network Information API (W3C) Ambient light sensor Battery Status API (W3C) Proximity sensor Alarm API Notification REGULAR APIS
  17. 17. BATTERY STATUS API
  18. 18. 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); }
  19. 19. NOTIFICATION
  20. 20. var notification = navigator.mozNotification; notification.createNotification( "See this", "This is a notification", iconURL );
  21. 21. SCREEN ORIENTATION API
  22. 22. // Portrait mode: screen.mozLockOrientation("portrait"); /* Possible values: "landscape" "portrait" "landscape-primary" "landscape-secondary" "portrait-primary" "portrait-secondary" */
  23. 23. VIBRATION API
  24. 24. // 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);
  25. 25. WEB PAYMENTS
  26. 26. var pay = navigator.mozPay(paymentToken); pay.onsuccess = function (event) { // Weee! Money! };
  27. 27. mozmarket.receipts.Prompter({ storeURL: "https://marketplace.mozilla.org/app/myapp", supportHTML: '<a href="mailto:me@example.com">email me@example.com</a>', verify: true });
  28. 28. DEVICEPROXIMITY
  29. 29. 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); });
  30. 30. AMBIENT LIGHT EVENTS
  31. 31. 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); });
  32. 32. PAGE VISIBILITY
  33. 33. document.addEventListener("visibilitychange", function () { if (document.hidden) { console.log("App is hidden"); } else { console.log("App has focus"); } });
  34. 34. Device Storage API Browser API TCP Socket API Contacts API systemXHR PRIVILEGED APIS
  35. 35. DEVICE STORAGE API
  36. 36. var deviceStorage = navigator.getDeviceStorage("videos");
  37. 37. 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; } };
  38. 38. WEB ACTIVITIES
  39. 39. Interacting with the camera
  40. 40. 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!"); };
  41. 41. { "activities": { "share": { "filters": { "type": ["image/png", "image/gif"] } "href": "sharing.html", "disposition": "window" } } }
  42. 42. Future APIs
  43. 43. Resource lock API Spellcheck API UDP Datagram Socket API LogAPI Peer to Peer API Keyboard/IME API WebNFC WebRTC WebUSB FileHandle API HTTP-cache API Sync API Calendar API
  44. 44. Web Apps from Mozilla
  45. 45. Dialer Alarm Clock Contacts Camera Settings Notes SMS First Run Experience Web browser Notifications Gallery Home Screen Video Player Mozilla Marketplace Music Player System Updater E-mail (POP, IMAP) Localization Support Calendar
  46. 46. Web Components & Mozilla Brick
  47. 47. http://mozilla.github.io/brick/
  48. 48. <x-flipbox> <div>I'm the front face.</div> <div>And I'm the back face.</div> </x-flipbox>
  49. 49. // assume that toggleButton and flipBox are already // defined as their respective DOM elements toggleButton.addEventListener("click", function(){ flipBox.toggle(); });
  50. 50. appbar calendar datepicker deck flipbox iconbutton layout slidebox slider tabbar toggle togglegroup tooltip
  51. 51. Get started
  52. 52. https://addons.mozilla.org/firefox/addon/firefox-ossimulator/
  53. 53. FIREFOX OS BOILERPLATE APP https://github.com/robnyman/Firefox-OS-Boilerplate-App
  54. 54. APP MANAGER
  55. 55. https://marketplace.firefox.com/
  56. 56. https://marketplace.firefox.com/developers/
  57. 57. Trying things out
  58. 58. Go have some fun!
  59. 59. Robert Nyman robertnyman.com robert@mozilla.com Mozilla @robertnyman
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×