SlideShare a Scribd company logo
Bringing the Open Web & APIs to
 mobile devices with Firefox OS
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
@robertnyman
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
Firefox OS




  Using HTML5, CSS and
  JavaScript together with a
  number of APIs to build
  apps and customize the UI.
Open Web Apps
https://developer.mozilla.org/docs/Apps/Getting_Started
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
Steps to Take
Develop Web App using
1.   HTML5, CSS, & Javascript


2.   Create an app manifest file



3.   Publish/install the app
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
1.
Develop Web App using
HTML5, CSS & JavaScript
Reuse any existing web site/app or develop from scratch with open
                          web standards.

   Utilize HTML5 features such as localStorage, offline manifest,
         IndexedDB and access Web APIs for more options.

  Responsive web design for adapting to varying resolutions and
                      screen orientation.
2.
Create an app manifest file
Create a file with a .webapp extension
{
  "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
Apache - in mime.types:

application/x-web-app-manifest+json webapp



Apache - in .htaccess:

AddType application/x-web-app-manifest+json webapp



NGinx - in mime.types:

types {
  text/html   html htm shtml;
  text/css    css;
  text/xml    xml;
  application/x-web-app-manifest+json   webapp;
}
IIS:

In IIS Manager, right-click the local
computer, and click Properties.

Click the MIME Types button.

Click New.

In the Extension box, type the file name
extension.

In the MIME type box, type a description
that exactly matches the file type defined
on the computer.

Click OK.
curl -I http://mozillalabs.com/manifest.webapp
3.
Publish/install the app
Firefox Marketplace
https://marketplace.firefox.com/
https://marketplace.firefox.com/developers/
Installing/hosting the app
var request = navigator.mozApps.install(
   "http://mozillalabs.com/MozillaBall.webapp",
   {
     user_id: "some_user"
   }
);

request.onsuccess = function() {
  // Success! Notification, launch page etc
}

request.onerror = function() {
  // Failed. this.error.name has details
}
Packaged vs. Hosted Apps
A packaged app is an Open Web App that has all of its resources
(HTML, CSS, JavaScript, app manifest, and so on) contained in a zip
       file, instead of having its resources on a Web server.

A packaged app is simply a zip file with the app manifest in its root
    directory. The manifest must be named manifest.webapp.
Can be privileged apps with more API access than hosted apps

Resources are accessed from the zip file, which is stored on the device where the
app is installed)

Enforce a specific Content Security Policy for all application content

Can embed remote content in iframes, but that content will not have access to
privileged APIs nor will it have the default CSP applied to it
https://developer.mozilla.org/docs/Apps/
          For_Web_developers
WebAPIs
https://wiki.mozilla.org/WebAPI
Security Levels
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
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 and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
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
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("lightlevel", function (event) {
    // Possible values: "normal", "bright", "dim"
    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                    WebBluetooth
WebSMS                          Permissions API
Idle API                        Network Stats API
Settings API                    Camera API
Power Management API            Time/Clock API
Mobile Connection API           Attention screen
WiFi Information API            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 and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
{
    "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 and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
Future APIs
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
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
Web Apps from Mozilla
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
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
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
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 and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
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 and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
https://lists.mozilla.org/listinfo/dev-webapps

             irc://irc.mozilla.org/
               #openwebapps
Trying things out
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland
Robert Nyman
robertnyman.com
robert@mozilla.com
Mozilla

   @robertnyman

More Related Content

PDF
Firefox OS workshop, JSFoo, India
PDF
WebAPIs & WebRTC - Spotify/sthlm.js
PDF
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
PDF
Firefox OS workshop, Colombia
PPTX
HTML5 on Mobile
PPT
Creating the interfaces of the future with the APIs of today
PDF
Android in practice
PDF
Silex: From nothing to an API
Firefox OS workshop, JSFoo, India
WebAPIs & WebRTC - Spotify/sthlm.js
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - Geek Meet
Firefox OS workshop, Colombia
HTML5 on Mobile
Creating the interfaces of the future with the APIs of today
Android in practice
Silex: From nothing to an API

What's hot (20)

PDF
JQuery UK Service Workers Talk
PDF
JQuery UK February 2015: Service Workers On Vacay
PDF
Connect.js - Exploring React.Native
PDF
WebAPIs + Brick - WebBR2013
PDF
How to Win on the Apple Watch
PDF
Connect.js 2015 - Building Native Mobile Applications with Javascript
PDF
Android swedroid
PDF
20130528 solution linux_frousseau_nopain_webdev
PDF
Search and play more than 50 clips
PDF
Finding Concurrency Errors in Event-Driven Applications - Strangeloop'14
PDF
What's new in Rails 4
PDF
The JavaFX Ecosystem
PDF
Dethroning Grunt: Simple and Effective Builds with gulp.js
PDF
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
PDF
Titanium - Making the most of your single thread
PDF
AnkaraJUG Kasım 2012 - PrimeFaces
PDF
Advanced Mac Software Deployment and Configuration: Just Make It Work!
PDF
developing Xul
PDF
feature flagging with rails engines v0.2
PPTX
Testing frontends with nightwatch & saucelabs
JQuery UK Service Workers Talk
JQuery UK February 2015: Service Workers On Vacay
Connect.js - Exploring React.Native
WebAPIs + Brick - WebBR2013
How to Win on the Apple Watch
Connect.js 2015 - Building Native Mobile Applications with Javascript
Android swedroid
20130528 solution linux_frousseau_nopain_webdev
Search and play more than 50 clips
Finding Concurrency Errors in Event-Driven Applications - Strangeloop'14
What's new in Rails 4
The JavaFX Ecosystem
Dethroning Grunt: Simple and Effective Builds with gulp.js
HTML5 kickstart - Brooklyn Beta workshop 21.10.2010
Titanium - Making the most of your single thread
AnkaraJUG Kasım 2012 - PrimeFaces
Advanced Mac Software Deployment and Configuration: Just Make It Work!
developing Xul
feature flagging with rails engines v0.2
Testing frontends with nightwatch & saucelabs
Ad

Viewers also liked (20)

PDF
0800z Royalty Finance Invitation
PDF
Conexa Comunicação
PPT
Mittelstand im Mittelpunkt: High End eCommerce
PDF
Baso 11-ybk-final
PDF
Aieee pt 5 2012
KEY
Presentación 30segons
PDF
Eleuthera island
PDF
Palmera final-22 de agosto- copia enviada a imprenta.
PPTX
Lazer e Diferenciais - Ph.D Personal Home Design - Barra Funda/SP
PDF
Kinesis Marketing Social Media Brochure
DOC
Devendra_Pawar
PDF
CRP0422 - Luz e Gambiarra
PPTX
Catedral slp
PDF
Brazilian Pipeline Community
PDF
Catalogue produits étanchéité Isocell 2016
PDF
Abogado, asesor, consultor litigante administrador de empresas inocencio mele...
PDF
An introduction to Zeversolar inverters
PPT
Los tehuelches Giuli.
PPTX
NAVIERA : AMERICAN PRESIDENT LINES (APL)
0800z Royalty Finance Invitation
Conexa Comunicação
Mittelstand im Mittelpunkt: High End eCommerce
Baso 11-ybk-final
Aieee pt 5 2012
Presentación 30segons
Eleuthera island
Palmera final-22 de agosto- copia enviada a imprenta.
Lazer e Diferenciais - Ph.D Personal Home Design - Barra Funda/SP
Kinesis Marketing Social Media Brochure
Devendra_Pawar
CRP0422 - Luz e Gambiarra
Catedral slp
Brazilian Pipeline Community
Catalogue produits étanchéité Isocell 2016
Abogado, asesor, consultor litigante administrador de empresas inocencio mele...
An introduction to Zeversolar inverters
Los tehuelches Giuli.
NAVIERA : AMERICAN PRESIDENT LINES (APL)
Ad

Similar to Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland (20)

PDF
WebAPIs & Apps - Mozilla London
PDF
Web APIs & Apps - Mozilla
PDF
JavaScript APIs - The Web is the Platform
PDF
Firefox OS learnings & visions, WebAPIs - budapest.mobile
PDF
Mozilla, Firefox OS and the Open Web
PDF
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
PDF
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
PPTX
Introduction to Apache Cordova (Phonegap)
PPT
Firefox os-introduction
PDF
The Open Web and what it means
PDF
Mozilla Web Apps - Super-VanJS
PDF
Firefox OS
PDF
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
PDF
WebRTC & Firefox OS - presentation at Google
PDF
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
PPTX
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
PDF
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
PPTX
HTML5 WebWorks
PPTX
Firefox OS Web APIs, taking it to the next level
KEY
Intro To webOS
WebAPIs & Apps - Mozilla London
Web APIs & Apps - Mozilla
JavaScript APIs - The Web is the Platform
Firefox OS learnings & visions, WebAPIs - budapest.mobile
Mozilla, Firefox OS and the Open Web
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Introduction to Apache Cordova (Phonegap)
Firefox os-introduction
The Open Web and what it means
Mozilla Web Apps - Super-VanJS
Firefox OS
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
WebRTC & Firefox OS - presentation at Google
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
HTML5 WebWorks
Firefox OS Web APIs, taking it to the next level
Intro To webOS

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)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
Modernizing your data center with Dell and AMD
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Monthly Chronicles - July 2025
Empathic Computing: Creating Shared Understanding
Modernizing your data center with Dell and AMD
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
“AI and Expert System Decision Support & Business Intelligence Systems”

Bringing the open web and APIs to mobile devices with Firefox OS - Whisky Web, Scotland

  • 1. Bringing the Open Web & APIs to mobile devices with Firefox OS
  • 7. Firefox OS Using HTML5, CSS and JavaScript together with a number of APIs to build apps and customize the UI.
  • 12. Develop Web App using 1. HTML5, CSS, & Javascript 2. Create an app manifest file 3. Publish/install the app
  • 14. 1. Develop Web App using HTML5, CSS & JavaScript
  • 15. Reuse any existing web site/app or develop from scratch with open web standards. Utilize HTML5 features such as localStorage, offline manifest, IndexedDB and access Web APIs for more options. Responsive web design for adapting to varying resolutions and screen orientation.
  • 16. 2. Create an app manifest file
  • 17. Create a file with a .webapp extension
  • 18. { "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" }
  • 19. MANIFEST CHECKER http://appmanifest.org/
  • 20. Serve with Content-type/MIME type: application/x-web-app-manifest+json
  • 21. Apache - in mime.types: application/x-web-app-manifest+json webapp Apache - in .htaccess: AddType application/x-web-app-manifest+json webapp NGinx - in mime.types: types { text/html html htm shtml; text/css css; text/xml xml; application/x-web-app-manifest+json webapp; }
  • 22. IIS: In IIS Manager, right-click the local computer, and click Properties. Click the MIME Types button. Click New. In the Extension box, type the file name extension. In the MIME type box, type a description that exactly matches the file type defined on the computer. Click OK.
  • 29. var request = navigator.mozApps.install( "http://mozillalabs.com/MozillaBall.webapp", { user_id: "some_user" } ); request.onsuccess = function() { // Success! Notification, launch page etc } request.onerror = function() { // Failed. this.error.name has details }
  • 31. A packaged app is an Open Web App that has all of its resources (HTML, CSS, JavaScript, app manifest, and so on) contained in a zip file, instead of having its resources on a Web server. A packaged app is simply a zip file with the app manifest in its root directory. The manifest must be named manifest.webapp.
  • 32. Can be privileged apps with more API access than hosted apps Resources are accessed from the zip file, which is stored on the device where the app is installed) Enforce a specific Content Security Policy for all application content Can embed remote content in iframes, but that content will not have access to privileged APIs nor will it have the default CSP applied to it
  • 37. 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
  • 39. "permissions": { "contacts": { "description": "Required for autocompletion in the share screen", "access": "readcreate" }, "alarms": { "description": "Required to schedule notifications" } }
  • 42. 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
  • 44. 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); }
  • 46. var notification = navigator.mozNotification; notification.createNotification( "See this", "This is a notification", iconURL );
  • 48. // Portrait mode: screen.mozLockOrientation("portrait"); /* Possible values: "landscape" "portrait" "landscape-primary" "landscape-secondary" "portrait-primary" "portrait-secondary" */
  • 50. // 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);
  • 52. var pay = navigator.mozPay(paymentToken); pay.onsuccess = function (event) { // Weee! Money! };
  • 54. var connection = window.navigator.mozConnection, online = connection.bandwidth > 0, metered = connection.metered;
  • 56. 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); });
  • 58. window.addEventListener("devicelight", function (event) { // The level of the ambient light in lux console.log(event.value); });
  • 59. window.addEventListener("lightlevel", function (event) { // Possible values: "normal", "bright", "dim" console.log(event.value); });
  • 60. 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); });
  • 61. Device Storage API Browser API TCP Socket API Contacts API systemXHR PRIVILEGED APIS
  • 63. var deviceStorage = navigator.getDeviceStorage("videos");
  • 64. // "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]);
  • 65. 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; } };
  • 67. 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") };
  • 68. WebTelephony WebBluetooth WebSMS Permissions API Idle API Network Stats API Settings API Camera API Power Management API Time/Clock API Mobile Connection API Attention screen WiFi Information API Voicemail CERTIFIED APIS
  • 70. // 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);
  • 71. // Place a call var cal = tel.dial(“123456789”);
  • 72. // 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); }); };
  • 74. // SMS object var sms = navigator.mozSMS; // Send a message sms.send("123456789", "Hello world!");
  • 75. // Recieve a message sms.onreceived = function (event) { // Read message console.log(event.message); };
  • 78. { "activities": { "share": { "filters": { "type": ["image/png", "image/gif"] } "href": "sharing.html", "disposition": "window" } } }
  • 79. 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!"); };
  • 80. var register = navigator.mozRegisterActivityHandler({ name: "view", disposition: "inline", filters: { type: "image/png" } }); register.onerror = function () { console.log("Failed to register activity"); }
  • 81. 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 });
  • 85. 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
  • 86. Web Apps from Mozilla
  • 88. 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
  • 93. FIREFOX OS BOILERPLATE APP https://github.com/robnyman/Firefox-OS-Boilerplate-App
  • 97. 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 }
  • 98. 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(); }