Native ←♥→ Web

Dominique Hazaël-Massieux, W3C

@dontcallmedom

Native ♥ Web

Dom

  • W3C
  • Mobile
  • Geek
  • French

This project is funded by the European Union through the Seventh Framework Programme (FP7/2010-2012) under grant agreement n°257800
- Mobile Web Applications (MobiWebApp)

UK & France
Driving the wrong way
Unit systems compared
Monarchy
British Food
UK & France at war
France taking over UK
UK trying unsuccessully to take over France
Sharing between UK & France
Love between UK & France
Native & Web at war?
Love between Native & Web
Love between Native & Web has brought kids of their own

Web inspired native apps

  • connected, mostly via HTTP
  • UI metaphores
  • search
  • layout systems inspired from CSS
  • OAuth

How can we steal back?

User Interactions

Rich UI

Mouse over this circle

The other side!

  • SVG
  • CSS3 animations & transformations
  • canvas

Touch interactions

window.addEventListener('touchstart', cb, false);
window.addEventListener('touchmove', cb, false);
window.addEventListener('touchend', cb, false);

Less typing

<input type='tel'>
<input type='date'>
<input type='email'>
<datalist><option value='…'></datalist>

Much less typing?

<input type="text" speech>

Notifications

navigator.Notification.createNotification(title,
                      body);

Connected

Connected

var client = new XMLHttpRequest();
client.open("POST", "/draw");
client.send({from: {x:0,y:0}, to: {x:50,y:50}});

Optimally Connected

if (navigator.connection.type) == "3g") { … }
var eventsource = new EventSource();
eventsource.onmessage = function(event) { … }

Remote whiteboard demo

Bidirectionally Connected

var socket = new WebSocket(
                   'ws://game.example.com:12010/updates');
socket.onopen = function () { …};

P2P Connected

var connection = new PeerConnection('STUNS example.net',
                          signalingCallback);

	

Hardware integration

Geolocation

navigator.geolocation.getCurrentPosition(…)
navigator.geolocation.watchPosition(…)

Accelerometer/gyroscope

window.addEventListener("deviceorientation", …);
window.addEventListener("devicemotion", …);

Camera / Mike

navigator.getUserMedia('video,audio', videoCallback)
function videoCallback(stream) { … }

Better browsers

Web Apps as First Class Citizens

Web Apps need to be treated as well as native apps
  • Application list
  • Application switch
  • Cookies Isolation

But…

Let’s not throw the baby with the bath water

or rather the Web with the Native water

Web is RESTful

Use server-side links, or on the client, make use of:

window.history.pushHistory()

Designing a Web app requires designing its possible states

Declarative rules

JavaScript rocks, but:

<html><head>
  <script>doEverthingWithJavaScript();</script>
</head><body></body></html>

really?

Compatible

Mobile Web is not Mobile WebKit

Designing for IE6 served us so well…

Love between Native & Web

Vive le Web !

Learn more