Transcript
Page 1: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

HTML, not just for desktops

Congreso Universitario Móvil

Firefox OS

2014-09-04

Frédéric Harper

Sr. Technical Evangelist @ Mozilla

@fharper | outofcomfortzone.net

Crea

tive

Com

mon

s: h

ttp:

//j.m

p/1q

M9o

BJ

Page 2: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Lo sentimos, no hablo español Thanks Google translate…

Page 3: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1hCZYIe

Page 4: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1ljZuJC

Page 5: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 6: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 7: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

38 billion devices connected in 2020

ABI Research - 2013-05-09 - http://j.mp/38billion

Page 8: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1gP4X4K

Page 9: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 10: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

What you deserve

Page 11: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 12: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Built with the Web

Using HTML5, CSS3 and JavaScript

with a number of APIs

to build apps.

Page 13: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

It’s open source

Page 14: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Some facts

•  Available in 26 countries

•  Primarly aimed at emerging & low

end markets

•  More countries soon

Page 15: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Some facts

Page 16: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 17: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 18: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 19: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 20: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 21: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

A Firefox OS app?

§  Creating a hosted or packaged app

§  Using §  Vanilla HTML5

§  Librairies…

§  Regular API

§  Privileged API

§  Certified API

Page 22: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

HTML5 + manifest (JSON) = Firefox OS app {

"version": “42",

"name": ”My amazing app",

"launch_path": "/index.html",

"description": ”My super amazing app do super amazing things",

"icons": {

"16": "/images/logo16.png”,},

"developer": {

"name": ”Frédéric Harper",

"url": "http://outofcomfortzone.net",

},

"default_locale": "en",

"permissions": {

"geolocation": {

"description": ”Get the long/lat of the user"

}

}

}

Page 23: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

DEMO App Manager + Emberjs todomvc

Page 24: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web APIs

Page 25: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web APIs – Regular •  Alarm API •  Ambient light sensor •  Archive API •  Battery Status API •  Geolocation API •  IndexedDB •  Network Information API •  Notifications API

•  Open WebApps •  Proximity sensor •  Push API •  Screen Orientation •  Vibration API •  Web Activities •  WebFM API •  WebPayment

packaged

hosted

Page 26: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Ambient Light Sensor

Page 27: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Ambient Light Sensor

window.addEventListener("devicelight", function (event) {

// The level of the ambient light in lux

// The lux values for "dim" typically begin below 50,

// and the values for "bright" begin above 10000

console.log(event.value);

});

Page 28: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

DEMO Boilerplate – Ambient Light Sensor

Page 29: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Battery Status

Page 30: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Battery Status

var battery = navigator.battery;

if (battery) {

var batteryLevel = Math.round(battery.level * 100) + "%",

 

charging = (battery.charging)? “yes" : "no",

chargingTime = parseInt(battery.chargingTime / 60, 10,

dischargingTime = parseInt(battery.dischargingTime / 60, 10);

 

battery.addEventListener("levelchange", setStatus, false);

battery.addEventListener("chargingchange", setStatus, false);

battery.addEventListener("chargingtimechange", setStatus, false);

}

Page 31: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

DEMO Boilerplate – Battery status

Page 32: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web APIs – Privileged •  Browser API •  Contacts API •  Device Storage API •  systemXHR •  TCP Socket API

packaged

Page 33: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Browser

Page 34: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Browser

<div>

<span id='location-bar'></span>

<button onclick='go_button_clicked()'>Go</button>

</div>

<div id='load-status'></div>

<div id='security-status'></div>

<img id='favicon'>

<div id='title'></div>

<iframe mozbrowser src=‘yoursite.com' id='browser'></iframe>

Page 35: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Browser

addEventListener('mozbrowserloadstart', function(e) {

//Do stuff

});

/*

Possible values:

"mozbrowserloadstart“ "mozbrowserloadend"

"mozbrowserlocationchange“ "mozbrowsertitlechange"

"mozbrowsericonchange“ "mozbrowsersecuritychange"

"mozbrowsercontextmenu“ "mozbrowsererror"

"mozbrowserkeyevent“ "mozbrowsershowmodalprompt"

"mozbrowseropenwindow“ "mozbrowserclose"

*/

Page 36: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web APIs – Certified •  Camera API •  Idle API •  Mobile Connection API •  Network Stats API •  Permissions API •  Power Management API •  Settings API •  Time/Clock API

•  Voicemail •  WebBluetooth •  WebSMS •  WebTelephony •  WiFi Information API

OS/OEM

Page 37: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web Activities

Page 38: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web Activities •  browse •  configure •  costcontrol •  dial •  Open •  new

•  mail •  websms/sms •  webcontacts/contact

•  pick •  record •  save-bookmark •  share •  view •  update

packaged

hosted

Page 39: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Pick var activity = new MozActivity({

name: "pick",

//Provide the data required

//by the filter of the activity

data: {

type: "image/jpeg"

}

});

Page 40: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Pick activity.onsuccess = function () {

var img = document.createElement("img");

if (this.result.blob.type.indexOf("image") != -1) {

img.src = window.URL.createObjectURL(this.result.blob);

}

};

activity.onerror = function () {

//error

};

Page 41: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Dial var call = new MozActivity({

name: "dial",

data: {

number: "+46777888999"

}

});

Page 42: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Web Activity Received Handler "activities": {

"pick": {

"filters": {

"type": ["image/jpeg", "image/png"]

},

"disposition": "inline",

"returnValue": true,

"href": "/index.html#pick"

}

}

Page 43: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Don’t forget to handle it! navigator.mozSetMessageHandler('activity', function(activityRequest) {

var option = activityRequest.source;

if (activityRequest.source.name === "pick") {

// Do something to handle the activity

if (picture) {

activityRequest.postResult(picture);

}

else {

activityRequest.postError("Unable to provide a picture");

}

}

});

Page 44: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1iZHGAW

Page 45: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

How to start

Page 46: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1iquK8Q

Page 47: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/Ilm7wx

Page 48: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Cordova & Phonegap

Page 49: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

API implementations •  Camera •  Contacts •  Device •  Device-motion •  Geolocation •  Orientation •  Vibration

Page 50: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Free phone!

http://j.mp/mozflame

Creative Commons: https://flic.kr/p/epEL3n

Page 51: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Simplicity…

Page 52: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Firefox Web Developer Tools

Page 53: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 54: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 55: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04
Page 56: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Creative Commons: http://j.mp/1gIdcPF

To infinity, and beyond…

Page 57: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

More Web APIs & features

•  Calendar API

•  FileHandle API Sync API

•  Keyboard/IME API WebRTC

•  HTTP-cache API

•  Peer to Peer API

•  Spellcheck API LogAPI

•  Resource lock API

•  UDP Datagram Socket API

•  WebNFC

•  WebUSB

Page 58: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Next time you’ll build a mobile app Think about HTML5

Page 59: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Resources Firefox OS Simulator http://j.mp/fxosSimulator Firefox OS App Manager http://j.mp/fxosAppManager Mozilla Developer Network https://developer.mozilla.org

StackOverflow forum http://j.mp/fxosStackOverflow Firefox OS Boilerplate http://j.mp/fxosBoilerplate

Page 60: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Planning to port or build a

Firefox OS app?

Please let me know!

Page 61: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Join us at 11:00 for a workshop

Page 62: HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 2014-09-04

Frédéric Harper

[email protected]

@fharper

http://hacks.mozilla.org

http://outofcomfortzone.net


Top Related