SlideShare a Scribd company logo
1 of 69
Download to read offline
!
WEB.BR 2013 	


#FirefoxOS
!
Fábio
Magnoni
@FabioMagnoni
#FirefoxOS
Construindo Apps
Open Web Apps
A Plataforma é a Web
Mobile Internet Users

Desktop
Plataformas
{

"version": "1.0",

"name": “Mozilla	
",

"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/"

}

},

"pt-BR": {

"description": "Descrição da sua aplicação!",

"developer": {

"url": "http://pt-BR.mozillalabs.com/"

}

}

},

"default_locale": "en"

}

VERIFICADOR DE MANIFESTO
http://appmanifest.org/
Packaged vs. Hosted Apps
WebAPIs
Segurança
Aplicações
Conteúdo Web

Apps Web Privilegiadas

Conteúdo Web comum

Mais acesso, mais
responsabilidades

App Web Instalada

App Web Certificada

Uma App Web comum

Apps críticas aos
aparelho (hardware)
Permissões

https://developer.mozilla.org/en-US/Apps/Developing/App_permissions
"permissions": {

"contacts": {

"description": "Required for autocompletion in the share screen",

"access": "readcreate"

},

"alarms": {

"description": "Required to schedule notifications"

}

}
WEB APIs
WEB APIS (PARA TODOS)
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
API STATUS DA
BATERIA
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);
}
NOTIFICAÇÃO
var notification = navigator.mozNotification;

notification.createNotification(

"See this", 

"This is a notification", 

iconURL

);
API ORIENTAÇÃO
DE TELA
// 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);
VISIBILIDADE DA
PÁGINA
document.addEventListener("visibilitychange", function (event) {

	
if (document.hidden) {
	
	
	
console.log(event."App is hidden");	
	
}	
	
else {	
	
	
console.log(event."App has focus");	
	 }

});
NETWORK INFO
API
var connection = window.navigator.mozConnection,

online = connection.bandwidth > 0,

metered = connection.metered;

PROXIMIDADE
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
EVENT
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);

});
WEB APIS (APPS PRIVILEGIADAS)
Device Storage API
Browser API
TCP Socket API
Contacts API
systemXHR
DEVICE STORAGE
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;

}

};
API DE CONTATOS
var addContact = document.querySelector("#add-contact");

if (addContact) { 

addContact.onclick = function () {

var newContact = new MozActivity({

name: "new", // Possibly add-contact in future versions

data: {

type: "webcontacts/contact",

params: { // Will possibly move to be direct properties under "data"

giveName: "Fabio",

familyName: "Magnoni",

tel: "+5519988013586",

email: "fabio@mozilla.com",

address: "Campinas",

note: “Se tiver cerveja envolvida, pode entrar em contato :)”,

company: "Mozilla"

}

}

});

}

}
Apps Certificadas
=
DO SO
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
WEB ACTIVITIES
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!");

};
{

"activities": {

"share": {

"filters": {

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

}

"href": "sharing.html",

"disposition": "window"

}

}

}
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

});
Como Instalar pela WEB

var install app = navigator.mozApps.install(manifestURL);

installapp.onsucess = function(data) {	
	
//App is installed

};	


installapp.onerror = function() {	
	
//App wasn’t installed, info is in	
	
// installapp.error.name	
};
APIs Futuras
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
https://marketplace.firefox.com/
o/ Docs e Ferramentas o/
FIREFOX OS
BOILERPLATE APP

https://github.com/robnyman/Firefox-OS-Boilerplate-App
https://addons.mozilla.org/firefox/addon/firefox-ossimulator/
http://buildingfirefoxos.com/
http://mozilla.github.io/brick/docs.html
Componentes
Appbar
!
Calendar
!
Deck
!
Flipbox
!
Layout
!
Slideshow
!
Slider
!
Tabbar
!
Toggle
!
Tooltip
Recursos
https://developer.mozilla.org/en-US/docs/WebAPI
https://marketplace.firefox.com/developers/
Mozilla Developer Blog

https://hacks.mozilla.org/category/firefox-os/
Precisa de ajuda?
https://lists.mozilla.org/listinfo/dev-webapps
irc://irc.mozilla.org/
#openwebapps
Fábio Magnoni

fabio@mozilla.com

@FabioMagnoni
@mozhacks

More Related Content

Similar to WebAPIs + Brick - WebBR2013

Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoFirefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Robert Nyman
 
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsFirefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Robert Nyman
 
Firefox OS workshop, Colombia
Firefox OS workshop, ColombiaFirefox OS workshop, Colombia
Firefox OS workshop, Colombia
Robert Nyman
 
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJSBringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
Robert Nyman
 
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJSBringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Robert Nyman
 
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 MeetBringing 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
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
Robert Nyman
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Firefox os-introduction
Firefox os-introductionFirefox os-introduction
Firefox os-introduction
zsoltlengyelit
 
(Christian heilman) firefox
(Christian heilman) firefox(Christian heilman) firefox
(Christian heilman) firefox
NAVER D2
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.js
Robert Nyman
 
Mozilla, Firefox OS and the Open Web
Mozilla, Firefox OS and the Open WebMozilla, Firefox OS and the Open Web
Mozilla, Firefox OS and the Open Web
Robert Nyman
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
Christian Heilmann
 
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSBuilding Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
FITC
 

Similar to WebAPIs + Brick - WebBR2013 (20)

Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoFirefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
 
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsFirefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
 
Firefox OS workshop, Colombia
Firefox OS workshop, ColombiaFirefox OS workshop, Colombia
Firefox OS workshop, Colombia
 
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJSBringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - BrazilJS
 
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJSBringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
Bringing the Open Web & APIs to 
mobile devices with Firefox OS - SpainJS
 
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 MeetBringing 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 and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
Firefox os-introduction
Firefox os-introductionFirefox os-introduction
Firefox os-introduction
 
(Christian heilman) firefox
(Christian heilman) firefox(Christian heilman) firefox
(Christian heilman) firefox
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.js
 
Web versus Native: round 1!
Web versus Native: round 1!Web versus Native: round 1!
Web versus Native: round 1!
 
So what's the Deal with Firefox OS - MobileTechCon Berlin 2014
So what's the Deal with Firefox OS - MobileTechCon Berlin 2014So what's the Deal with Firefox OS - MobileTechCon Berlin 2014
So what's the Deal with Firefox OS - MobileTechCon Berlin 2014
 
Mozilla, Firefox OS and the Open Web
Mozilla, Firefox OS and the Open WebMozilla, Firefox OS and the Open Web
Mozilla, Firefox OS and the Open Web
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
 
Firefox OS - A (web) developers dream - muxCamp 2014
Firefox OS - A (web) developers dream - muxCamp 2014Firefox OS - A (web) developers dream - muxCamp 2014
Firefox OS - A (web) developers dream - muxCamp 2014
 
Pivorak.javascript.global domination
Pivorak.javascript.global dominationPivorak.javascript.global domination
Pivorak.javascript.global domination
 
Andriy Vandakurov about "Frontend. Global domination"
Andriy Vandakurov about  "Frontend. Global domination" Andriy Vandakurov about  "Frontend. Global domination"
Andriy Vandakurov about "Frontend. Global domination"
 
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSBuilding Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

WebAPIs + Brick - WebBR2013