SlideShare a Scribd company logo
Building great mobile web
apps: Some things you
might want to know
     By Shwetank Dixit, Opera Software
about me
Web Evangelist, Opera Developer
Relations Team

Member, W3C Mobile Web for Social
Development Group

Member, W3C Web Education
Community Group

twitter.com/shwetank
email: shwetankd@opera.com
“All the pieces matter...”
           - Lester Freemon, The Wire
We’re (mainly) going to
talk about slick web apps
on full featured mobile
browsers
But first spare a thought
for the low powered
devices which can’t run a
full featured browser
But first spare a thought
for the low powered
devices which can’t run a
full featured browser
      IT CONSTITUTES A MAJORITY OF THE MOBILE WEB
              (AS OF RIGHT NOW AND THE NEAR TERM)
The most important thing
to know about the mobile
web...
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
Just one Web
Smartphone browsers != Webkit
Furthermore, which webkit
are you talking about?
 READ PPK’S ARTICLE TITLED “THERE IS NO WEBKIT ON MOBILE”
It’s ok if the same site
looks different in different
devices
As long as they are optimized for it.
But if you do have a
different mobile site...
ALWAYS provide a link to switch back to the
desktop version.
Building great mobile apps: Somethings you might want to know
W3C Mobile Web Best
Practices guidelines
RTFG
Offline webapps
with html5
Offline Apps: Storing the
files need to run offline
CACHE MANIFEST
      #this is a comment.

           style.css
           script.js
          index.htm



contents of the manifest file.
<html manifest=”demo.manifest”>


Linking the manifest file to the html page.
CACHE MANIFEST
              #this is a comment.

                   style.css
                   script.js
                  index.htm

                  NETWORK:
               dynamicpage.php



The NETWORK: section header bypasses the cache
CACHE MANIFEST
                 #this is a comment.

                      style.css
                      script.js
                     index.htm

                     FALLBACK:
               original.jpg backup.jpg


If a file can’t load, then the FALLBACK: section header
specifies which files to load as a backup in their place
ALWAYS KEEPING AN UPDATED CACHE


                          �
�
Offline Apps: Storing the
data for offline use
Storage: Web Storage
The problem with cookies
Unreliable
No programmatic APIs to manipulate it
Not structured

Most of important of all ...
Small file size, so very limited data can be
stored.
Web Storage
Session Storage and Local Storage
localStorage.setItem(yourkey,
yourvalue); // Store the value

var item = localStorage.getItem
(yourkey); // Retrieve the value and assign
it to a variable
Example of using Web Storage to store and
retrieve values in the browser’s local storage
With this, even if you close the browser and re-open the page again, the values should
still load properly.
You can store images (and
more) with localStorage
                 ....BUT DON”T.
Automatically save entered
form info locally
in case page crashes or closes, person can
resume from where he left off
STORE USER DATA OFFLINE
         PERIODICALLY


�
�
Or...
You could save only when you detect a new
keystroke (or a minimum number of them)
Gotcha
Two tabs updating the same value
Storage events
Know if some other page has changed the
value or not
GET NEW VALUE IF ITS BEEN CHANGED
         IN PARALLEL TAB
�
�
�
Gotcha
Using a free hosting service - Don’t use local
storage with it if they store users accounts
on different directories.

e.g, freehosting.com/user1
and freehosting.com/user2
Other storage
options
- IndexedDB (Limited browser support currently)
- WebSQL (Standard in impasse. Limited desktop browser
support but nice mobile browser support.)
Further reading
Run your web apps offline with HTML5 Application Cache: http://dev.opera.com/
articles/view/offline-applications-html5-appcache/

Web Storage: easier, more powerful client-side data storage: http://dev.opera.com/
articles/view/web-storage/

Taking your web apps offline: A tale of Web Storage, Application Cache and WebSQL:
http://dev.opera.com/articles/view/taking-your-web-apps-offline-web-storage-
appcache-websql/
Media queries
�




Provide different styles to different
resolutions using media queries
Traditionally, mobile browsers provide a
‘zoomed out’ view, and then you can tap in
Viewport meta tag
Allows you to set the zooming level
Building great mobile apps: Somethings you might want to know
Scaling constraints
<meta name="viewport"
content="width=device-width,
maximum-scale=2, minimum-scale=0.5">
Disable user scaling
<meta name="viewport"
content="width=device-width,
user-scalable=no">
In Opera, you can use CSS
to control viewport
For example...

@-o-viewport {
  width: device-width;
  max-zoom: 2;
  min-zoom: 0.5;
}
Geolocation
Find yourself
“These are my thoughts in
a well published format”
-The early web
“Here is what we can all
do together”
- “Web 2.0”
“This is what I’m thinking”
- Facebook, twitter and other social tools
“This is where I’m at”
- The next step
Think of the possibilities
Augmented reality
Geofencing
location aware advertising
...more
//Check if browser supports W3C Geolocation API
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition
(successFunction, errorFunction);
} else {
    alert('Geolocation not supported.');
}
Sample code for running geolocation, if
available
function successFunction(position) {
  var lat = position.coords.latitude;
  var long = position.coords.longitude;
  alert('Your latitude is :'+lat+' and longitude is '+long);
}

Determining the position
function errorFunction(position){
 if (pos.PositionError == 1){
 alert('It seems you have decided not to share your
location');
 }
 if (pos.PositionError == 2){
 alert('The location could not be determined by the
browser. Try to reload the page to try again');
 }

Handling errors
SEE FULL LIST OF ERRORS ON THE SPEC
watchPosition()
Same as getCurrentPosition() but fires
whenever there is a change in location.

Sometimes its better to use this than the
former.
Accuracy
Scarily accurate in some places,
amusingly inaccurate in others.

DO NOT rely on it.
Provide fallbacks, and ways to enter location
info manually (like zipcode)
The Geolocation Spec
May be up for a bit of a change in the future
Further reading
How to use the W3C Geolocation API: http://dev.opera.com/articles/view/how-to-use-
the-w3c-geolocation-api/

Use the Geolocation API in Webapps: http://goo.gl/EBVYt
A sneak peak
Device Orientation
Access to gyroscope, accelerometer info etc
Access gyroscope info
window.addEventListener
("deviceorientation", function(event) {

      // process event.alpha, event.beta and
event.gamma

   }, true);
Access accelerometer info
window.addEventListener("devicemotion",
function(event) {

     // Process event.acceleration

   }, true);
Another sneak peak
Check for access
if (navigator.getUserMedia){
 	 navigator.getUserMedia('video', v_success,
v_error);
 }

else{
 	 not_supported();
 }
Check for access
var video_element = document.querySelector('video');
...
...
function v_success(stream){
 	 video_element.src = stream;
}
Use camera + <video> +
<canvas> for new tricks
var button = document.querySelector('#button');
button.addEventListener('click',snapshot, false);
...
...
function snapshot(){
 	 var c = document.querySelector('canvas');
 	 var ctx = c.getContext('2d');
 	 var cw = c.clientWidth;
 	 var ch = c.clientHeight;
 	 ctx.drawImage(video_element, 0, 0, cw, ch);
 }
Keep in mind
WebRTC spec (containing getUserMedia) is
still in flux. Not a mature standard yet.
Download the Opera
Mobile labs build with
device orientation and
getUserMedia support
Download from here: http://my.opera.com/core/blog/2011/03/23/webcam-
orientation-preview
Read up on
Dev.opera.com
Cheers!
More questions? Ask me now or contact me
at:
shwetankd@opera.com
or, twitter.com/shwetank

More Related Content

PDF
WebRTC - On Standards, Identity and Telco Strategy
PDF
WebRTC: A front-end perspective
PDF
WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...
PPTX
WebRTC
PDF
WebRTC on Mobile Devices: Challenges and Opportunities
PPTX
Implementation Lessons using WebRTC in Asterisk
PPTX
WebRTC overview
PDF
WebRTC Reborn SignalConf 2016
WebRTC - On Standards, Identity and Telco Strategy
WebRTC: A front-end perspective
WebRTC Tutorial by Dean Bubley of Disruptive Analysis & Tim Panton of Westhaw...
WebRTC
WebRTC on Mobile Devices: Challenges and Opportunities
Implementation Lessons using WebRTC in Asterisk
WebRTC overview
WebRTC Reborn SignalConf 2016

What's hot (20)

PPTX
Introduction to WebRTC
PPTX
Practical webRTC - from API to Solution - webRTC Summit 2014 @ NYC
PPTX
KITE Network Instrumentation: Advanced WebRTC Testing
PPTX
Real-Time Communication Testing Evolution with WebRTC
PPTX
WebRTC Seminar Report
PPT
Introduction To Webrtc
PPTX
Webrtc plugins for Desktop Browsers
PDF
WebRTC DataChannels demystified
PPTX
WebRTC Status Update - 2017Q2
PPTX
DevCon5 (July 2014) - Intro to WebRTC
PDF
WebRTC Check-in (from WebRTC Boston 6)
PPTX
DevCon5 (July 2014) - Acision SDK
PDF
Quality Assurance for WebRTC Services
PPTX
WebRTC presentation
PDF
DevCon 5 (December 2013) - WebRTC & WebSockets
PDF
Getting started with WebRTC
PDF
WebRTC beyond Audio and Video
PDF
Asterisk World (January 2014) - Taking Enterprise Telephony into the Web World
PDF
Janus conf'19: janus client side
Introduction to WebRTC
Practical webRTC - from API to Solution - webRTC Summit 2014 @ NYC
KITE Network Instrumentation: Advanced WebRTC Testing
Real-Time Communication Testing Evolution with WebRTC
WebRTC Seminar Report
Introduction To Webrtc
Webrtc plugins for Desktop Browsers
WebRTC DataChannels demystified
WebRTC Status Update - 2017Q2
DevCon5 (July 2014) - Intro to WebRTC
WebRTC Check-in (from WebRTC Boston 6)
DevCon5 (July 2014) - Acision SDK
Quality Assurance for WebRTC Services
WebRTC presentation
DevCon 5 (December 2013) - WebRTC & WebSockets
Getting started with WebRTC
WebRTC beyond Audio and Video
Asterisk World (January 2014) - Taking Enterprise Telephony into the Web World
Janus conf'19: janus client side
Ad

Viewers also liked (20)

PPTX
Rosa (2n A)
PPTX
Manel V.
PPTX
Inspiring news trends and innovations 2013
PPTX
Taming the tiger - pnwphp
PPS
Que diferença faz uma estação......
PDF
Centrust Savings Bank - Business Card
PPTX
Thais C. (2n A)
PPTX
Sc oct 2015 the hottest free sourcing tools available dean da costa
DOC
Plan de desarrollo municipal de aldana nariño
PPTX
Mysteriousmilitary facts (2)
PDF
Habilidades sociales
PPTX
Ai Lead Scoring And Lead Rating
PDF
W3C/Webkit test integration presentation
PDF
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...
PPT
Open Annotation Collaboration Briefing
PDF
openMIC barcamp 11.02.2010
PDF
Node.js, le pavé dans la mare
PDF
HTML5 and XHTML2
Rosa (2n A)
Manel V.
Inspiring news trends and innovations 2013
Taming the tiger - pnwphp
Que diferença faz uma estação......
Centrust Savings Bank - Business Card
Thais C. (2n A)
Sc oct 2015 the hottest free sourcing tools available dean da costa
Plan de desarrollo municipal de aldana nariño
Mysteriousmilitary facts (2)
Habilidades sociales
Ai Lead Scoring And Lead Rating
W3C/Webkit test integration presentation
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...
Open Annotation Collaboration Briefing
openMIC barcamp 11.02.2010
Node.js, le pavé dans la mare
HTML5 and XHTML2
Ad

Similar to Building great mobile apps: Somethings you might want to know (20)

PDF
Html5 and beyond the next generation of mobile web applications - Touch Tou...
PDF
Building an Appier Web - London Web Standards - Nov 2016
PDF
Building an Appier Web - Velocity Amsterdam 2016
PPTX
HTML5 on Mobile
PPT
HTML 5 Offline Web apps
PDF
Html5 storage suggestions for challenges.pptx
PDF
Offline for web - Frontend Dev Conf Minsk 2014
PDF
Offline of web applications
PDF
Building an Appier Web - May 2016
PDF
Web fundamentals
PDF
Creating Rajanikant Powered Site
PDF
The Mobile Web - HTML5 on mobile devices
PDF
your browser, your storage
PPT
Krug Fat Client
KEY
HTML5와 모바일
PDF
Get Ahead with HTML5 on Moible
PDF
Your browser, your storage (extended version)
PPTX
Dave Orchard - Offline Web Apps with HTML5
PPTX
PPTX
Taking Web Applications Offline
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Building an Appier Web - London Web Standards - Nov 2016
Building an Appier Web - Velocity Amsterdam 2016
HTML5 on Mobile
HTML 5 Offline Web apps
Html5 storage suggestions for challenges.pptx
Offline for web - Frontend Dev Conf Minsk 2014
Offline of web applications
Building an Appier Web - May 2016
Web fundamentals
Creating Rajanikant Powered Site
The Mobile Web - HTML5 on mobile devices
your browser, your storage
Krug Fat Client
HTML5와 모바일
Get Ahead with HTML5 on Moible
Your browser, your storage (extended version)
Dave Orchard - Offline Web Apps with HTML5
Taking Web Applications Offline

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Machine learning based COVID-19 study performance prediction
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Understanding_Digital_Forensics_Presentation.pptx
sap open course for s4hana steps from ECC to s4
Unlocking AI with Model Context Protocol (MCP)
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Machine learning based COVID-19 study performance prediction
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation theory and applications.pdf

Building great mobile apps: Somethings you might want to know