SlideShare a Scribd company logo
Mobile Web Architecture
Structure, architecture and capabilities of hybrid mobile
applications
Contact Me
•

Ynon Perek	


•

ynon@ynonperek.com	


•

http://ynonperek.com
Agenda
Introduction to Hybrid Apps (+Phonegap)

1

HTML5 Features for Hybrid Apps

2

Push Notifications

3
Why is mobile 	


different?
Questions To Ask for Mobile
•

How does my solution:	

•

Affects battery life ?	


•

Affects network traffic ?	


•

Deal with interruptions ?	


•

Deal with connectivity ?	


•

Respects user’s privacy ?
Choosing Mobile Technology
Problems With Native

•

Too many different programming languages
Problems With Native

•

Too many different programming languages	


•

“Same app”, different code
Web is not perfect either
•

Code runs in a browser:	

•

Slower	


•

Restricted by the browser
Web vs. Native
Native

Web
Browser

App
App
Hybrid Apps

Web Content

Native App Wrapper
Demo: Implementing A 

Hybrid Solution
Hybrid Architecture
Web
Content
Native Wrapper
3rd party
extensions

Server + DB
Takeaways

•

Hybrid architecture provides the good AND bad
from both worlds	


•

Understanding the platform is necessary
Hybrid Apps +
•

Most of the app is written once	


•

Only native parts are written again and again	


•

“Feels” native	


•

Developer controls native code => can use native
APIs
Hybrid Apps •

Complex code	


•

Requires knowledge in many programming
languages	


•

Data is transferred between environments	


•

Hard to debug
Let’s Analyse A Hybrid App
•

Hystagram is a hybrid
version of instagram with
minimal functionality	


•

Supports:	

•

Taking photos	


•

Watching photos	


•

Uploading photos to
server
Processes and scopes
Process

Take a photo

Upload photo to server

View photo stream

Scope

Why
Processes and scopes
Process

Take a photo

Upload photo to server

View photo stream

Scope

Why

Native

Need to show a camera
overlay
Processes and scopes
Process

Take a photo

Upload photo to server

View photo stream

Scope

Why

Native

Need to show a camera
overlay

Native

Upload must continue
when app is not active
Processes and scopes
Process

Scope

Why

Native

Need to show a camera
overlay

Upload photo to server

Native

Upload must continue
when app is not active

View photo stream

Web

Because we can

Take a photo
Introducing Phonegap
Introducing Phonegap
•

An open source connection layer between web
content and native	


•

Extensible	


•

Supported platforms: 

iOS, Android, Blackberry, WebOS, Windows
Phone, Symbian, Bada
Q&A
Agenda
Introduction to Hybrid Apps (+Phonegap)

1

HTML5 Features for Hybrid Apps

2

Push Notifications

3
The Web Side
Users and Sessions	

Location	

Camera	

Video	

Audio
Web 101
HTTP Request

HTTP Response
HTTP and state

•

HTTP is stateless	


•

This means server has no way to know two
requests originated from the same client
Cookies
•

Bits of data saved on a device and sent to the
server with each HTTP request	


•

Used to store state	


•

Demo
Session Management
Login: user, pass
Client

Server

DB
Session Management
Login: user, pass
Verify: user, pass
Client

Server

DB
Session Management
Login: user, pass
Client

Save session
Server

DB
Session id
Session Management
Login: user, pass
Save session
Client

Set Cookie: 	

Session id

Server

DB
Session id
Session Management Options
•

Session id on client, Session data on server	


•

Encrypted session data on client, key on server	


•

RESTful
RESTful Web Services

•

Server provides resources	


•

Resources are in known conventional URLs
RESTful Web Services
/collection

/collection/item

GET

Returns an array of
items

Returns details for a
specific item

POST

Create a new item

PUT
DELETE

Modify an existing item
Delete the collection

Delete an item
RESTful authentication
•

Client uses a private authentication token to
access restricted resources	


•

Demo: 

https://developers.facebook.com/tools/explorer
What You Should Use
What You Should Use
•

For web clients, cookies are the easiest	


•

If possible, prefer to store only session id in the
cookie	


•

For other clients, consider a token
Q&A
Geolocation
•

Detect where your user is
now	


•

Show nearby places	


•

Display location aware data	


•

Enable location specific
features
Technologies
•

GPS	


•

A-GPS	


•

Cell Information	


•

WiFi Positioning
GPS
•

Global Positioning System	


•

Accuracy error: 2-10m	


•

Requires clear sky view 	


•

Time to position: 

5 seconds - 5 minutes
A-GPS

•

Uses both GPS chip and
network information to get
location	


•

Much faster to get location
Cell Information
•

Uses cell towers to
calculate a device’s location	


•

Accuracy: A block or up to
some km	


•

Time to location: immediate
WiFi Positioning

•

Detect location using a list
of wireless routers in your
area	


•

Relies on existing router
databases
Permissions

•

Browser asks user
permissions before sharing
location	


•

Best practice: Request
location just before using it
Location Failures
•

Location services don’t
always work	


•

Why ?	


•

What do you do when
you’re lost ?
Location API
1 navigator.geolocation.getCurrentPosition(

successCallback, 


2
3
6
7

failureCallback,	

4
{	

5
timeout: 0,	

maximumAge: 60000,	

enableHighAccuracy: false	

8
});
Using A Map
Show Me The Map
•

Both iOS and Android have built in maps
applications	


•

Open the built-in maps application using a simple
link	


•

Demo
Built-In Maps +

•

Great UI	


•

User feels “at home”
Built-In Maps -

•

User leaves the app
When To Use

•

Use built-in maps app for navigation	


•

Use embedded maps for geo-data related to your
app
Map APIs
•

Google Maps	


•

Open Street maps	


•

Demo:

https://developers.google.com/maps/
documentation/javascript/examples/map-simple
Q&A
Taking Photos
getUserMedia

•

Desktop browsers support the new getUserMedia
API	


•

Demo: http://shinydemos.com/photo-booth/
getUserMedia Browser Support
Using The Camera

•

iOS >= 6; Android >= 3	


•

<input type="file" field opens camera app
Normal <input> capture="camera" accept="image/*"
id="takePictureField">

What You Can Do
•

Take a picture and send it to server	


•

Analyse picture on the client - Demo	


•

Apply filters or edit - Demo
What You Still Can’t Do

•

Can’t check if camera is available	


•

No camera overlay
Q&A
VIDEO
THE EASY WAY
Video Tag
•

HTML5 introduces a <video> tag to embed
videos in a web page.	


•

Different browsers support different video
formats. The <video> tag can specify multiple
formats.
Video Formats
•

Video formats are like
languages	


•

The same video can be
encoded in different
formats	


•

A browser must “speak the
language” to be able to play
the video
Video Converter

•

Miro is a free open source
video player and converter	


•

http://www.getmiro.com
Browser Support
•

HTML5 spec does not define a video codec to
use	


•

h.264 is the most widely supported. Plays on
iPhone and Android
The Markup

<video poster=”star.png”>	

<source src=”zebra.mp4” />	

</video>	

!
Limitations: Autoplay
“ Apple has made the decision to disable the
automatic playing of video on iOS devices,
through both script and attribute
implementations.”

Issue 159336: 	

 	

On Android, html5 video autoplay attribute
does not work.
Limitations: Play Inline
“ Currently, Safari optimizes video
presentation for the smaller screen on
iPhone or iPod touch by playing video using
the full screen
”

Videos play inline for Android >= 3
Playing Audio
HTML5 Audio	

Audio API
Audio Tag
•

New addition of HTML5	


•

Simple to use	


•

Both HTML tag and JS api
Audio Tag
<audio src="scifi002.mp3" controls="YES"></audio>
Audio Tag JS API
audio.src = 	

“http://static1.grsites.com/archive/sounds/scifi/scifi002.mp3";	




audio.pause();

audio.currentTime = 0;

audio.play();

Audio Tag

•

Demo	


•

Play a gun fire sound when button is clicked
Audio Tag Limitations on Mobile
•

Not accurate (has short delays)	


•

Starts to load sound after user interaction	


•

Can’t control the audio data
Audio API

•

A new improved API for playing sounds	


•

Timing considerations built-in
Audio API Browser Support
Audio API Architecture

Audio Context
Source

Destinatio
n
Audio Context
Source

Gain
(volume)

Destinatio
n
Quiz

How do you implement cross fade ?
Cross Fade
Audio Context
Source

Gain
(volume)
Destinatio
n

Source

Gain
(volume)
Audio API: What You Can Do
•

Apply audio filters (using filter nodes)	


•

Change volume (using gain nodes)	


•

Merge multiple audio sources to one destination	


•

Play with accurate timing
Audio API Demo
•

Same game as before	


•

This time no delays in playing the audio	


•

More complex demo:

http://labs.dinahmoe.com/ToneCraft/#
Recording Audio

•

getUserMedia() will allow audio recording	


•

Not yet supported on mobile
Q&A
Agenda
Introduction to Hybrid Apps (+Phonegap)

1

HTML5 Features for Hybrid Apps

2

Push Notifications

3
User’s Perspective
Marketer’s Perspective
“

For the first time in human
history, you can tap almost
two billion people on the
shoulder.
”
Developer’s Perspective

•

What is a notification ?
Developer’s Perspective

•

What is a notification ?	


•

User visible information reflecting some event
Developer’s Perspective

•

Why should I use notifications ?
Developer’s Perspective

•

Why should I use notifications ?	


•

Ensure time-sensitive delivery when your app isn’t
running
Developer’s Perspective

•

How does push compared to poll ?
Developer’s Perspective

•

How does push compared to poll ?	


•

Pushes are server driven and immediate, polls are
app driven and latent
Keep In Mind

•

Push notifications are not reliable	


•

(even if the APN server gets them)
Types Of Notifications

•

Badges (iOS only)	


•

Alerts
Push Service Architecture
Your Server

User’s Device

Push
Notification
Server
Getting A Token
Sending A Notification
Demo App
•

A simple push chat room hybrid app	


•

HTML layer handles user interface	


•

Native layer receives notifications
Server: Sending A Notification
my $notifier = $APNS->notify({	

cert => "cert.pem",	

key => "key.pem",	

passwd => "1234"	

});	

!

$notifier->devicetoken($device_token);	

$notifier->message("message");	

$notifier->sound('default');	

$notifier->custom({ custom_key => 'custom_value' });	

$notifier->sandbox(1);	

!

$notifier->write;
APNS Best Practices
•

Keep the connection open	


•

Use multiple connections to the gateway	


•

Be polite with your users
Q&A
Thanks For Listening
•

Ynon Perek	


•

ynon@ynonperek.com	


•

http://ynonperek.com
Photos Used In The Slides
•

Choices (slide 6):

http://www.flickr.com/photos/danmoyle/
11715566974/sizes/l/	


•

Man with camera (slide 43):

http://bit.ly/1gb5ZZM

More Related Content

PDF
Lublin Startup Festival - Mobile Architecture Design Patterns
ODP
Developing Exceptional Mobile Application
PDF
Mobile App Development
PPTX
IBM Worklight for Digital Agencies
PPTX
Kony one studio technical training
PDF
What's great in Appcelerator Titanium 0.8
KEY
Real-world Dojo Mobile
PDF
Creating Mobile Content Using Flash
Lublin Startup Festival - Mobile Architecture Design Patterns
Developing Exceptional Mobile Application
Mobile App Development
IBM Worklight for Digital Agencies
Kony one studio technical training
What's great in Appcelerator Titanium 0.8
Real-world Dojo Mobile
Creating Mobile Content Using Flash

What's hot (20)

PDF
Adobe AIR Mobile development for Android and PlayBook
KEY
Flash Builder and Flex Future - Multiscreen Development
PDF
Mobile applications chapter 2
PPTX
Mobile applications chapter 5
PDF
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
PDF
Android ActionBar Navigation reloaded
PDF
Cordova + Ionic + MobileFirst
PDF
Session 7 - Overview of the iOS7 app development architecture
PPTX
Building solutions on the Microsoft platform that target iPhone, iPad, and An...
KEY
HTML5 로 iPhone App 만들기
ZIP
Mobile for the rest of us
PPTX
Javascript frameworks
PDF
One APK to rule them all
PDF
Native vs Hybrid vs Web
PDF
Mobile Applications Architecture - GDG Ternopil' Architecture Components Meetup
PPTX
Building apps for multiple devices
PPTX
Cross-Platform Development using Angulr JS in Visual Studio
PPTX
Kony plaform short
PPTX
Mobile applications chapter 4
PDF
Native vs Hybrid - Options to develop your mobile application
Adobe AIR Mobile development for Android and PlayBook
Flash Builder and Flex Future - Multiscreen Development
Mobile applications chapter 2
Mobile applications chapter 5
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Android ActionBar Navigation reloaded
Cordova + Ionic + MobileFirst
Session 7 - Overview of the iOS7 app development architecture
Building solutions on the Microsoft platform that target iPhone, iPad, and An...
HTML5 로 iPhone App 만들기
Mobile for the rest of us
Javascript frameworks
One APK to rule them all
Native vs Hybrid vs Web
Mobile Applications Architecture - GDG Ternopil' Architecture Components Meetup
Building apps for multiple devices
Cross-Platform Development using Angulr JS in Visual Studio
Kony plaform short
Mobile applications chapter 4
Native vs Hybrid - Options to develop your mobile application
Ad

Viewers also liked (10)

PPT
Introduction to Location-Based Service (LBS)
PPTX
The New 3-Tier Architecture: HTML5, Proxies, and APIs
PPTX
WhatsApp architecture
PDF
Whatsapp's Architecture
PDF
High Scalability by Example – How can Web-Architecture scale like Facebook, T...
PDF
YouTube Content strategy
PDF
Facebook Architecture - Breaking it Open
PPT
7 Stages of Scaling Web Applications
PDF
facebook architecture for 600M users
PDF
Architecture of a Modern Web App
Introduction to Location-Based Service (LBS)
The New 3-Tier Architecture: HTML5, Proxies, and APIs
WhatsApp architecture
Whatsapp's Architecture
High Scalability by Example – How can Web-Architecture scale like Facebook, T...
YouTube Content strategy
Facebook Architecture - Breaking it Open
7 Stages of Scaling Web Applications
facebook architecture for 600M users
Architecture of a Modern Web App
Ad

Similar to Architecture app (20)

PDF
Workshop HTML5+PhoneGap by Ivano Malavolta
PDF
HTML5: the new frontier of the web
PDF
HTML5 and the dawn of rich mobile web applications
PPTX
Hybrid Mobile App
PPTX
Hybrid mobile app
PDF
JSON over SMS
PDF
AppsFuel, il nuovo marketplace per mobile web app e mobile site!
PPSX
Developing Downloadable Mobile Apps Using HTML5 and PhoneGap
PPTX
HTML5 on Mobile
PPTX
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
PPT
Thadomal IEEE-HTML5-Workshop
PDF
Hybrid application development
KEY
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
PPTX
Mobile Apps Develpment - A Comparison
PDF
Hybrid mobile apps
PDF
Web, Native & Hybrid Apps Overview
PDF
Hybrid HTML5 Apps
PPT
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
PPTX
HTML5: The Apps, the Frameworks, the Controversy
PPTX
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
Workshop HTML5+PhoneGap by Ivano Malavolta
HTML5: the new frontier of the web
HTML5 and the dawn of rich mobile web applications
Hybrid Mobile App
Hybrid mobile app
JSON over SMS
AppsFuel, il nuovo marketplace per mobile web app e mobile site!
Developing Downloadable Mobile Apps Using HTML5 and PhoneGap
HTML5 on Mobile
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
Thadomal IEEE-HTML5-Workshop
Hybrid application development
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
Mobile Apps Develpment - A Comparison
Hybrid mobile apps
Web, Native & Hybrid Apps Overview
Hybrid HTML5 Apps
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
HTML5: The Apps, the Frameworks, the Controversy
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova

More from Ynon Perek (20)

PDF
Regexp
PDF
Html5 intro
PDF
09 performance
PDF
Mobile Web Intro
PDF
Qt multi threads
PDF
Vimperl
PDF
Syllabus
PDF
Mobile Devices
PDF
Network
PDF
Cryptography
PDF
Unit Testing JavaScript Applications
PDF
How to write easy-to-test JavaScript
PDF
Introduction to Selenium and Ruby
PDF
Introduction To Web Application Testing
PDF
Accessibility
PDF
Angularjs
PDF
Js memory
PDF
Qt Design Patterns
PDF
Web Application Security
PDF
JavaScript DOM Manipulations
Regexp
Html5 intro
09 performance
Mobile Web Intro
Qt multi threads
Vimperl
Syllabus
Mobile Devices
Network
Cryptography
Unit Testing JavaScript Applications
How to write easy-to-test JavaScript
Introduction to Selenium and Ruby
Introduction To Web Application Testing
Accessibility
Angularjs
Js memory
Qt Design Patterns
Web Application Security
JavaScript DOM Manipulations

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation theory and applications.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Approach and Philosophy of On baking technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Approach and Philosophy of On baking technology
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Architecture app