Native & Progressive Web Apps

+

Julien Evano

Tech Lead - Software Engineer

with

2

Who am I?

  • Software Engineer & Front End Tech Lead

 

  • Advisory Board Member - Software Engineering

@Cashwerkz

@Leezair

@julienevano

Julien Evano

julienevano

Personal mobile apps

Budget Forecast

Sydney Expat Guide

Music Queue Player

Ionic 2

Angular 2

Firebase 3

Webpack

Ionic

AngularJS

Gulp

Objective-C

julienevano

Hybrid & PWA

Hybrid

Native

What is a Progressive Web App?

  • App-like - Web App that acts like native
  • Installable, Fresh - Saved to home screen and always up-to-date
  • Connectivity independent - Offline functionality
  • No App Store - No review process
  • Progressive - Works on every platform
  • Re-engageable - Push notification support
  • Discoverable, Linkable - easily found through search and access via URL

Progressive Web App

or P.W.A.

  • Safe - Served via HTTPS

Which type of mobile app should I develop?

Mobile strategy

4 types of mobile app

Native

Native JS

Hybrid

P.W.A

Mobile strategy

4 categories of analysis

Distribution

Capabilities

Performance

Productivity

Mobile strategy

Native

Native JS

Hybrid

P.W.A.

Capabilities

Performance

No single strategy has to be used in isolation

There’s no one-size-fits-all

https://youtu.be/FP1w89F5OtI

Productivity

Distribution

Analysis

Mobile strategy

Productivity

Native

Native JS

Hybrid

P.W.A.

Framework

Language

Number of team profiles

Code base & Build

  • iOS SDK
  • Android SDK
  • Windows Universal SDK

NativeScript

or

ReactNative

Cordova

or

Phonegap

Any Web framework

with native like capability

  • Swift / Objective-C
  • Java
  • .Net

HTML

CSS subset

JS / TS

HTML

CSS

JS / TS

HTML

CSS

JS / TS

Multiple

Single

Single

Single

3

1

1

1

Mobile strategy

Capabilities & Performance

Native

Native JS

Hybrid

P.W.A.

UI components

Native API

Offline

Push notification

Native

HTML, CSS, JS

in WebView

HTML, CSS, JS

Yes

Yes

Yes

Yes

Yes

Only Android for now

Yes

Yes

Yes

Yes

Native

Yes

Yes

No

Mobile strategy

Distribution

Native

Native JS

Hybrid

P.W.A.

Installation / Update

Searchability

Store

Web

Store

Web via Website

Web

1st time experience

Installation = friction = abandonment

Native experience

on the web

Why Ionic 2?

Code once. Deploy everywhere.

  • Built on top of Angular - advanced framework with an active community
  • Native like UI - Standard native mobile app UI guidelines for each OS
  • Native SDKs - via Ionic Native and Cordova
  • Hybrid App - uses Cordova to deploy natively
  • Progressive Web App - Runs in the browser
  • Powerful CLI
  • Performance obsessed - Hardware accelerated transitions, touch-optimized gestures, native scrolling

Why Webpack?

  • Module bundler - not just a task runner
  • Analyzes dependencies among your modules  and generates assets not only JS but also CSS, HTML, images, etc...
  • Understands multiple standards for how to define dependencies and export values - AMD, CommonJS, ES6 modules, ...
  • A lot of plugins to optimise builds, generate resources and manage offline capability - e.g. NekR/offline-plugin

How to build

a Progressive Web App with Ionic 2?

Create an Ionic App

# Install ionic tools
$ npm install -g ionic 

# Create Ionic 2 project
$ ionic start AngularHackDayIonic2PWA --v2 

# Build the project
$ ionic build 

http://ionicframework.com/docs/v2/getting-started/installation/

Web app manifest

{
  "name": "Angular Hack Day Ionic 2 PWA",
  "short_name": "AngularHackDay",
  "description": "Ionic 2 PWA demo for Angular Hack Day - Sydney",
  "start_url": "index.html",
  "display": "standalone",
  "orientation": "portrait",
  "background_color": "#79C273",
  "theme_color": "#79C273",
  "icons": [{
    "src": "../resources/android/icon/drawable-ldpi-icon.png",
    "sizes": "36x36",
    "type": "image/png"
  }, 
  ...
  ],
  "related_applications": [{
    "platform": "web",
    "url": "https://.../"
  }]
}

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json

Enable home screen install

Service Workers

https://developers.google.com/web/fundamentals/getting-started/primers/service-workers

  • Cache data & files
  • Send push notifications
  • Intercept network requests
  • Run by browser in the background

Enable offline capability

https://serviceworke.rs/

Service Workers

https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle

Install

Service Workers

https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle

Update

App Cache

https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache

For incompatible browsers

As a fallback

https://goo.gl/ec1p6N

  • Offline browsing - navigate even when offline
  • Speed - fast loading via local cached resources
  • No partial update - a byte-by-byte manifest comparison to trigger the update
  • Deprecated - Service Workers offers a replacement for Application Cache
  • Reduced server load - only downloads resources that have changed
  • No background sync -  local cache only

App Shell

https://developers.google.com/web/fundamentals/architecture/app-shell

Enable instant loading

Demo

https://github.com/julienevano/angularhackday-ionic2-pwa-demo

Thank you

@julienevano

julienevano

julienevano

Contact me

Resources

  • Angular Connect 2016
  • Building Progressive Web Apps and Hybrid Apps with Ionic Adam Bradley and Brandy Carney - https://youtu.be/seOk-PejrMc
  • Mobile apps? Trust no one except me Jeff Cross - https://youtu.be/FP1w89F5OtI
  • Ionic Framework - http://ionicframework.com
  • Mozilla Developer Framework - https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker
  • Google Developer - https://developers.google.com/web/progressive-web-apps/
  • Webpack Module Bundler - https://webpack.github.io/
  • Slides - https://slides.com/julienevano/native-and-progressive-web-app-with-ionic2-and-webpack

Native & Progressive Web App with Ionic 2 + Webpack

By Julien Evano

Native & Progressive Web App with Ionic 2 + Webpack

Ionic 2 allows you to create hybrid (installed as native app) and progressive web app from a single code base. Webpack optimises the the builds for you and reduce the size of the app to a maximum. Angular Hack Day - Sydney, Australia - 5th November 2016 - http://angularhackday.com/sydney/

  • 4,136