self.conference / Detroit / May 30, 2014
{computer,web,mad} scientist
{tech,scifi} writer
home{brew,roast}er
Mozillian
Mozilla & Firefox OS
Apps & the Open Web
Web APIs & Web Activities
Developer Tools
Seriously, what about native?
“Our mission is to promote openness, innovation & opportunity on the Web.”
“As a result of the intense competition among browser makers — a fight incited by Mozilla, then joined by Apple, Google and, lately, by Microsoft, whose share of the browser market has plummeted in the last decade — desktop web browsers have improved vastly over the past few years. They’re now ferociously fast, they can load and keep open hundreds of tabs, they’re extremely stable and they’re capable of handling highly complex websites.”
— Farhad Manjoo
(The New York Times, 2 May 2014)
“The success of our mission depends on participation from people like you.”
“Firefox OS is a new mobile operating system, developed by Mozilla, and based on Linux and the Gecko engine that powers Firefox.”
“Mozilla’s strategy has been to build Firefox OS primarily for emerging markets, where there are still billions of people who have yet to experience their first smartphone.”
~7 mobile operator partners, ~3 hardware partners
Appetizers!
Appetizers!
No!
“...an "app" is really much more than just a shortened slang term. It's not just the term that's shortened, and it's not just the term that's slanged. It's also the application itself that's shortened and slanged...”
— Ian Bogost (21 Jan 2011)
Single task
Limited attention
Focused UX
Touch UI
Cost $1 to $5
($50 is really pushing it)
“Telling developers that web apps are iPhone apps just doesn’t fly. Think about it this way: If web apps —
which are only accessible over a network;
which don’t get app icons in the iPhone home screen;
which don’t have any local data storage
— are such a great way to write software for iPhone,
then why isn’t Apple using this technique for any of their own iPhone apps?”
— John Gruber
(Daring Fireball, 11 Jun 2007)
localStorage | Offline | |
IndexedDB | AppCache | |
History | Video | |
Geolocation | Audio | |
Touch Events | Canvas | |
Drag and Drop | WebGL | |
Web Workers | Media Capture | |
Web Sockets | WebRTC |
https://my-app.example.com/manifest.webapp
Content-Type: application/x-web-app-manifest+json
{
"name": "My App",
"description": "My elevator pitch goes here",
"launch_path": "/index.html",
"icons": {
"128": "/img/icon-128.png"
},
"developer": {
"name": "Your name or organization",
"url": "http://your-homepage-here.org"
},
"default_locale": "en"
}
var manifestUrl = 'https://my-app.example.com/manifest.webapp';
var request = window.navigator.mozApps.install(manifestUrl);
request.onsuccess = function () {
// Save the App object that is returned
var appRecord = this.result;
alert('Installation successful!');
};
request.onerror = function () {
// Display the error information from the DOMError object
alert('Install failed, error: ' + this.error.name);
};
Web Activities | Network Information | Battery Status |
Screen Orientation | Device Orientation | Ambient Light |
Proximity Sensor | Device Storage | FM Radio |
Alarm | Vibration | Notifications |
Gamepad | Payment | TCP Sockets |
Telephony | SMS | Push |
window.navigator.vibrate(200);
window.navigator.vibrate([200, 100, 200]);
var battery = navigator.battery ||
navigator.mozBattery || navigator.webkitBattery;
function updateBatteryStatus() {
console.log("Battery status: " + battery.level * 100 + " %");
if (battery.charging) {
console.log("Battery is charging");
}
}
battery.addEventListener("chargingchange", updateBatteryStatus);
battery.addEventListener("levelchange", updateBatteryStatus);
updateBatteryStatus();
/* For portrait, we want the tool bar on top */
@media screen and (orientation: portrait) {
#toolbar { width: 100%; }
}
/* For landscape, we want the tool bar stick on the left */
@media screen and (orientation: landscape) {
#toolbar { position: fixed; width: 2.65em; height: 100%; }
}
var screen = window.screen;
screen.addEventListener("orientationchange", function () {
console.log("The orientation of the screen is: " +
screen.orientation);
});
screen.lockOrientation('landscape');
function handleOrientation(event) {
var absolute = event.absolute;
var z_rot = event.alpha;
var x_rot = event.beta;
var y_rot = event.gamma;
// Do stuff with the new orientation data
}
window.addEventListener("deviceorientation", handleOrientation,
true);
{
// Other App Manifest related stuff
// Activity registration
"activities": {
// The name of the activity to handle (here "pick")
"pick": {
"href": "./pick.html",
"disposition": "inline",
"filters": {
"type": ["image/*","image/jpeg","image/png"]
},
"returnValue": true
}
}
}
navigator.mozSetMessageHandler('activity', function(activityRequest) {
var option = activityRequest.source;
if (option.name === "pick") {
// Do something to handle the activity
...
// Send back the result
if (picture) {
activityRequest.postResult(picture);
} else {
activityRequest.postError("Unable to provide a picture");
}
}
});
var activity = new MozActivity({
// Ask for the "pick" activity
name: "pick",
// Provide the data required by
// the filters of the activity
data: { type: "image/jpeg" }
});
activity.onsuccess = function() {
var picture = this.result;
console.log("A picture has been retrieved");
};
activity.onerror = function() {
console.log(this.error);
};
“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 privileged app is one that makes use of privileged APIs ... When submitted to the Firefox Marketplace, privileged apps are approved using a special process. This process gives users of the app a level of assurance that the app has been carefully reviewed for potential security, privacy and capability issues.”
"permissions": {
"contacts": {
"description": "Required for autocompletion",
"access": "readcreate"
},
"alarms": {
"description": "Required to schedule notifications"
}
}
“A certified app is one that makes used of certified APIs, APIs that offer access to critical system function such as the default dialer or the system settings app on a device. ... A certified app must be approved for a device by the OEM or carrier.”
{ live demo goes here }