Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)

Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)

Progressive Web Apps sind ein plattformübergreifend einsetzbares Anwendungsmodell auf Web-Basis. Dank Project Fugu, einer Initiative der Chrome-Contributors Google, Microsoft und Intel, wird das Web um noch mächtigere Features erweitert. Damit können Entwickler endlich auch Produktivitäts-Apps wie Büro- und Bearbeitungsprogramme oder IDEs sinnvoll ins Web bringen.

In diesem Workshop zeigt Ihnen Christian Liebel von Thinktecture, wie Sie mit Angular Produktivitätsapps auf Desktopniveau entwickeln können – Zugriff auf das Dateisystem und die Zwischenablage sowie Dateizuordnungen inklusive. Und Sie können mitentwickeln: Bitte bringen Sie dazu Ihr Notebook (ohne Corporate-Proxys/Unternehmensrichtlinien) mit installiertem Google Chrome Canary, Node.js und Microsoft Visual Studio Code mit.

Christian Liebel

October 19, 2023
Tweet

More Decks by Christian Liebel

Other Decks in Programming

Transcript

  1. Progressive Web Apps
    für Desktop und Mobile mit Angular
    (Hands-on)
    Christian Liebel
    @christianliebel
    Consultant

    View full-size slide

  2. Hello, it’s me.
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Christian Liebel
    Twitter:
    @christianliebel
    Email:
    christian.liebel
    @thinktecture.com
    Angular & PWA
    Slides:
    thinktecture.com
    /christian-liebel

    View full-size slide

  3. 13:30–15:00 Block 1
    15:15–15:45 Coffee Break
    15:45–17:00 Block 2
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Timetable

    View full-size slide

  4. Things NOT to expect
    - Blueprint for PWA
    development
    - No AuthN/AuthZ
    Things To Expect
    - Extensive/up-to-date insights
    into PWA and Project Fugu
    - A productivity app use case
    that works on your desktop &
    smartphone
    - Lots of fun
    - Hands-on exercises
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Web Apps

    View full-size slide

  5. https://paint.js.org
    – Productivity app
    – Draw images
    – Lots of actions & tools
    – Installable
    – Read/save files
    – Copy/paste images
    from/to clipboard
    – Share files to other apps
    – Register for file extensions
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Demo Use Case

    View full-size slide

  6. (Workshop Edition)
    – Productivity app
    – Draw images
    – Lots of actions & tools
    – Installable
    – Read/save files
    – Copy/paste images
    from/to clipboard
    – Share files to other apps
    – Register for file extensions
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Demo Use Case

    View full-size slide

  7. Setup complete?
    (Node.js, Google Chrome, Editor, Git)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Setup (1/3)
    LAB #0

    View full-size slide

  8. git clone https://github.com/thinktecture/
    angular-days-2023-fall-pwa.git
    cd angular-days-2023-fall-pwa
    npm i
    npm start -- --open
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Setup (3/3)
    LAB #0

    View full-size slide

  9. Paint PWA Capabilities
    Progressive
    Enhancement
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Agenda

    View full-size slide

  10. Paint PWA Capabilities
    Progressive
    Enhancement
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Agenda

    View full-size slide

  11. Canvas
    – Plain bitmap for the web
    – Cross-platform, hardware-
    accelerated graphics
    operations
    – Supports different contexts
    (2D, 3D: WebGL, WebGL 2.0)
    – Supported on all evergreen
    browsers and on IE 9+
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint

    View full-size slide

  12. Canvas
    Add a canvas element to app.component.html:

    Query the canvas element in app.component.ts:
    @ViewChild('canvas') canvas?: ElementRef;
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint
    LAB #1

    View full-size slide

  13. Canvas 2D Context
    fillRect(x, y, width, height)
    strokeRect(x, y, width, height)
    beginPath()
    moveTo(x, y)
    lineTo(x, y)
    fill()
    stroke()
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint

    View full-size slide

  14. Canvas 2D Context
    1. Introduce a new field at the top of
    app.component.ts:
    context?: CanvasRenderingContext2D;
    2. Get the 2D context in ngAfterViewInit():
    const canvas =
    this.canvas!.nativeElement;
    const ctx = canvas.getContext('2d')!;
    this.context = ctx;
    3. Prepare the canvas:
    ctx.fillStyle = 'white';
    ctx.fillRect(0, 0,
    canvas.width,
    canvas.height);
    ctx.fillStyle = 'black';
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint LAB #2

    View full-size slide

  15. Low-latency Rendering
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint
    Web pages need to synchronize
    with the DOM on graphics updates
    causing latencies that can make
    drawing difficult
    Low-latency rendering skips
    syncing with the DOM with can lead
    to a more natural experience
    Supported on Chrome (Chrome OS
    and Windows only)

    View full-size slide

  16. Low-latency Rendering
    Opt-in to low-latency rendering (app.component.ts):
    const ctx = canvas.getContext('2d', {
    desynchronized: true
    })!;
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint
    LAB #3

    View full-size slide

  17. Pointer Events
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint
    Users nowadays use different
    input methods, cross-platform
    apps should cover all of them
    Pointer Events offer an
    abstract interface to catch all
    input methods (pointerdown,
    pointermove, pointerup)
    event.offsetX/event.offsetY
    contain the pointer’s position
    relative to the listener

    View full-size slide

  18. Pointer Events
    1. In app.component.html, add event bindings for the pointer events:
    (pointerdown)="onPointerDown($event)"
    (pointermove)="onPointerMove($event)"
    (pointerup)="onPointerUp()"
    >
    2. In app.component.ts (onPointerMove()), draw the user input:
    this.context!.fillRect(event.offsetX, event.offsetY, 2, 2);
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint LAB #4

    View full-size slide

  19. Bresenham Line Algorithm
    The user may move faster than
    the input can be processed
    For this case, we need to
    remember the previous point
    and interpolate the points in
    between
    The Bresenham line algorithm
    calculates the missing pixels
    between two given points
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint

    View full-size slide

  20. Bresenham Line Algorithm
    1. At the top of app.component.ts, a field called previousPoint to store
    the previous point:
    previousPoint?: { x: number, y: number };
    2. In onPointerDown(), set the current point as the previous point:
    this.previousPoint = { x: event.offsetX, y: event.offsetY };
    3. In onPointerUp(), set this.previousPoint to undefined.
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint LAB #5

    View full-size slide

  21. Bresenham Line Algorithm
    4. In onPointerMove(), call the Bresenham line algorithm with the points:
    if (this.previousPoint) {
    const currentPoint = { x: event.offsetX, y: event.offsetY };
    for (const point of
    this.paintService.bresenhamLine(this.previousPoint,
    currentPoint)) {
    this.context!.fillRect(point.x, point.y, 2, 2);
    }
    this.previousPoint = currentPoint;
    }
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint LAB #5

    View full-size slide

  22. Color Selection
    For this demo, we will only
    implement the brush tool. However,
    we want to bring in some color.
    A simple method to implement a
    color selection is to use the HTML
    color-type input element that
    shows the native color picker:

    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint

    View full-size slide

  23. Color Selection
    1. In app.component.html, replace the content of the node with:

    2. In app.component.ts (onColorChange()), update the context’s fill style
    accordingly:
    this.context!.fillStyle = color.value;
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Paint
    LAB #6

    View full-size slide

  24. Paint PWA Capabilities
    Progressive
    Enhancement
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Agenda

    View full-size slide

  25. für Desktop und Mobile mit Angular (Hands-on)
    Progressive Web Apps
    Responsive Linkable Discoverable Installable App-like
    Connectivity
    Independent
    Fresh Safe Re-engageable Progressive

    View full-size slide

  26. Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Web App
    Manifest
    Service
    Worker

    View full-size slide

  27. Web App Manifest
    Distinguishes Web Apps from
    Websites
    JSON-based file containing
    metadata for apps only
    Apps can be identified by search
    engines, app store providers, etc.
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  28. manifest.webmanifest
    {
    "short_name": "Paint",
    "name": "Paint Workshop",
    "theme_color": "white",
    "icons": [{
    "src": "icon.png",
    "sizes": "512x512"
    }],
    "start_url": "/index.html",
    "display": "standalone",
    "shortcuts": [/* … */]
    }
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    Names
    Icons
    Display Mode
    Shortcuts
    Start URL
    Theme color (status bar/window bar)

    View full-size slide

  29. Manifest Display Modes
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    browser minimal-ui standalone fullscreen

    View full-size slide

  30. Manifest Icon Purposes
    (any)
    any context (e.g. app icon)
    monochrome
    different color requirements
    maskable
    user agent masks icon as required
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    Safe Zone
    Windows iOS Android

    View full-size slide

  31. Web App Manifest
    1. Stop the npm start command, then run the following command to
    add PWA support to the current project:
    npm run ng add @angular/pwa
    2. In manifest.webmanifest,
    a) set name and short_name to values of your choice
    b) change the theme_color to #000080
    c) change the background_color to #808080
    3. In index.html, change the theme-color to #000080.
    4. Run npm start again.
    5. Test manifest in DevTools: F12 > Application > Manifest
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA LAB #7

    View full-size slide

  32. Manifest Shortcuts
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    Secondary entrypoints for your
    application (e.g., home screen
    quick actions, jump lists, …)
    Static definition in Web App
    Manifest
    Dynamic API may follow in the
    future
    Supported by Google Chrome
    for Android, macOS and
    Windows

    View full-size slide

  33. Web App Manifest
    1. In manifest.webmanifest, add (at least) the following shortcut:
    "shortcuts": [{
    "name": "About Paint",
    "short_name": "About",
    "description": "Show information about Paint",
    "url": "./",
    "icons": [{ "src": "assets/icons/icon-512x512.png", "sizes": "512x512" }]
    }]
    2. Test in DevTools: F12 > Application > Manifest
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    LAB #8

    View full-size slide

  34. Web App Manifest – Chromium Install Criteria
    1. Web App is not already installed
    2. Meets a user engagement heuristic (user has interacted with origin or
    viewed the page for at least 30 seconds)
    3. Includes a Web App Manifest that has short_name or name, at least a
    192px and 512px icon, a start_url and a display mode of
    fullscreen, standalone or minimal-ui
    4. Served over HTTPS
    5. Service workers
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    https://web.dev/articles/install-criteria

    View full-size slide

  35. Service Worker
    JavaScript executed in an own
    thread, registered by the website
    Acts as a controller, proxy, or
    interceptor
    Has a cache to store responses (for
    offline availability and performance)
    Can wake up even when the website
    is closed and perform background
    tasks (e.g., push notifications or sync)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  36. Service Worker
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    Service
    Worker
    Internet
    Website
    HTML/JS
    Cache
    fetch

    View full-size slide

  37. NgServiceWorker
    Angular CLI supports Service
    Worker generation by simply
    adding PWA support:
    ng add @angular/pwa
    One-size-fits-all Service
    Worker
    Pre-defined functionality,
    limited customizability
    PWA
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Web Apps

    View full-size slide

  38. Workbox
    Toolchain by Google
    Includes a CLI
    Generates a service worker
    implementation from directory
    contents (e.g., build output, or
    our development directory)
    Allows you to modify the
    service worker behavior
    (maximum flexibility)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  39. Service Worker
    1. In your console, run: npm run pwa
    2. Test in DevTools: F12 > Application > Service Worker
    3. Install the app: Address Bar > Install
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    LAB #9

    View full-size slide

  40. Push Notifications
    Just as native apps, PWAs can
    receive push notifications
    Combination of two technologies:
    Web Notifications and Push API
    Supported by Chrome, Edge,
    Firefox, Safari
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  41. Service Worker Debugging
    More information on installed
    service workers can be found on
    • about://serviceworker-
    internals (Chromium-based
    browsers)
    • about:serviceworkers
    (Mozilla Firefox)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  42. Service Worker Debugging
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA

    View full-size slide

  43. Lighthouse
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    Auditing tool by Google,
    integrated in Chrome DevTools
    Automatically checks
    performance metrics, PWA
    support, accessibility, SEO and
    other best practices and gives
    tips on how to improve
    Can simulate mobile devices

    View full-size slide

  44. Lighthouse
    1. Make sure only one tab/window of your PWA is open
    2. Open DevTools: F12 > Lighthouse
    3. Make sure to select at least the “Progressive Web App” category
    4. Click “Analyze page load”
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    PWA
    LAB #10

    View full-size slide

  45. Paint PWA Capabilities
    Progressive
    Enhancement
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Agenda

    View full-size slide

  46. Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)

    View full-size slide

  47. Project Fugu
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    »Let’s bring the web
    back – API by API«
    Thomas Steiner, Google

    View full-size slide

  48. Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    Contacts
    Picker
    Screen Wake
    Lock API
    File System
    Access API
    Shape
    Detection API

    View full-size slide

  49. Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    https://goo.gle/fugu-api-tracker

    View full-size slide

  50. Browser
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    navigator.share({ url: 'http://example.com' });
    ShareIntent DataTransferManager

    NSSharingServicePicker

    View full-size slide

  51. File System Access API
    Some applications heavily rely
    on working with files (e.g.
    Visual Studio Code, Adobe
    Photoshop, …)
    File System Access API allows
    you to open, save and override
    files and directories
    Supported by Chrome, Edge
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities

    View full-size slide

  52. File System Access API
    1. Add the following buttons to the bar in app.component.html
    (before the color input):
    Open
    Save
    Copy
    Paste
    Share
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #11

    View full-size slide

  53. File System Access API
    2. Add the following lines at the top of app.component.ts:
    readonly fileOptions: FilePickerOptions = {
    types: [{
    description: 'PNG files',
    accept: {'image/png': ['.png']}
    }]
    };
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #11

    View full-size slide

  54. File System Access API
    3. Add the following lines to the save() function:
    const blob = await
    this.paintService.toBlob(this.canvas!.nativeElement);
    const handle = await
    window.showSaveFilePicker(this.fileOptions);
    const writable = await handle.createWritable();
    await writable.write(blob);
    await writable.close();
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #11

    View full-size slide

  55. File System Access API
    Add the following code to the open() function:
    const [handle] = await
    window.showOpenFilePicker(this.fileOptions);
    const file = await handle.getFile();
    const image = await this.paintService.getImage(file);
    this.context!.drawImage(image, 0, 0);
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #12

    View full-size slide

  56. Async Clipboard API
    Allows reading from/writing to
    the clipboard in an
    asynchronous manner (UI won’t
    freeze during long-running
    operations)
    Reading from the clipboard
    requires user consent first
    (privacy!)
    Supported by Chrome, Edge
    and Safari and Firefox (plain-
    text only)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities

    View full-size slide

  57. Async Clipboard API
    Add the following code to the copy() function:
    await navigator.clipboard.write([
    new ClipboardItem({ "image/png":
    this.paintService.toBlob(this.canvas!.nativeElement) }),
    ]);
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #13

    View full-size slide

  58. Async Clipboard API
    const clipboardItems = await navigator.clipboard.read();
    for (const clipboardItem of clipboardItems) {
    for (const type of clipboardItem.types) {
    if (type === 'image/png') {
    const blob = await clipboardItem.getType(type);
    const image = await this.paintService.getImage(blob);
    this.context!.drawImage(image, 0, 0);
    }
    }
    }
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #14

    View full-size slide

  59. Web Share API
    Allows sharing a title, URL, text, or
    files
    API can only be invoked as a
    result of a user action (i.e. a click
    or keypress)
    Supported by Chrome, Edge,
    Safari and Firefox (Android only)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities

    View full-size slide

  60. Web Share API
    const blob = await
    this.paintService.toBlob(this.canvas!.nativeElement);
    const file = new File([blob], 'untitled.png', {type:
    'image/png'});
    const item = { files: [file] };
    if (navigator.canShare(item)) {
    await navigator.share(item);
    }
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #15

    View full-size slide

  61. File Handling API
    Register your PWA as a
    handler for file extensions
    Requires installing the
    application first
    Declare supported extensions
    in Web App Manifest and add
    imperative code to your
    application logic
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities

    View full-size slide

  62. File Handling API
    1. Add the following property to your manifest (manifest.webmanifest):
    "file_handlers": [{
    "action": "/index.html",
    "accept": {
    "image/png": [".png"]
    }
    }]
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #16

    View full-size slide

  63. File Handling API
    2. Add the following code to ngAfterViewInit() in app.component.ts:
    if ('launchQueue' in window) {
    window.launchQueue.setConsumer(async params => {
    const [handle] = params.files;
    if (handle) {
    const file = await handle.getFile();
    const image = await this.paintService.getImage(file);
    ctx.drawImage(image, 0, 0);
    }
    });
    }
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #16

    View full-size slide

  64. File Handling API
    3. Rebuild PWA: npm run pwa
    Note: Wait for a few seconds and reload the application after opening,
    as the PWA needs to fetch the new files first.
    about://apps
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities
    LAB #16

    View full-size slide

  65. Summary
    - Project Fugu helps the web to become more and more capable
    - Project Fugu APIs could bring many more app experiences to the web
    (IDEs, productivity apps, etc.)
    - But: Web is threatened by alternative approaches and platforms,
    support for modern Web API varies from platform to platform
    - You can make a difference!
    - File bugs in browser engine bugtrackers
    - File Fugu requests: https://goo.gle/new-fugu-request
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Capabilities

    View full-size slide

  66. Paint PWA Capabilities
    Progressive
    Enhancement
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Agenda

    View full-size slide

  67. Overview
    Use available interfaces and functions of
    a system (opposite of Graceful
    Degradation)
    Users with modern, feature-rich
    browsers get a better experience
    Apps are available on older browsers, but
    with limited functionality
    Concept: Browser feature support should
    grow over time—thereby more users can
    enjoy an increasing number of features
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Enhancement

    View full-size slide

  68. Overview
    if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register(…)
    .then(() => /* … */);
    }
    In JavaScript: check whether an API/feature is available. If yes—use it!
    Otherwise:
    1. Disable the functionality
    2. Fall back to an alternative API (if available)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Enhancement

    View full-size slide

  69. Disabling unsupported features
    In app.component.ts, introduce the following check object:
    readonly supported = {
    open: 'showOpenFilePicker' in window,
    } as const;
    In app.component.html, disable the open button if the API is unsupported:

    Open
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Enhancement LAB #17
    Für localhost:4200

    View full-size slide

  70. Disabling unsupported features
    Introduce checks for the remaining APIs:
    1. Save: 'showSaveFilePicker' in window
    2. Copy: navigator.clipboard && 'write' in navigator.clipboard
    3. Paste: navigator.clipboard && 'read' in navigator.clipboard
    4. Share: 'canShare' in navigator
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Enhancement LAB #17

    View full-size slide

  71. Providing an alternative implementation
    1. In the save() method of app.component.ts, test for the existence of
    the showSaveFilePicker() method on the window object.
    2. If the method does not exist, fall back to the following code for save:
    const anchor = document.createElement('a');
    const url = URL.createObjectURL(blob);
    anchor.href = url;
    anchor.download = '';
    anchor.click();
    URL.revokeObjectURL(url);
    3. Remove the compatibility check to always enable the button.
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Progressive Enhancement LAB #18

    View full-size slide

  72. Deployment
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Electron/Capacitor
    JS
    HTML
    CSS
    .ipa
    .exe .app ELF
    .apk .appx
    Single-Page
    Application
    Capacitor
    Electron

    View full-size slide

  73. (Simplified)
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Store Deployments
    https://example.com
    .appx
    .apk
    Server
    Microsoft
    Store
    Play
    Store
    Source
    Files

    View full-size slide

  74. Run app on your device
    npm run pwa
    https://ngrok.com/download
    ngrok http 3000
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    LAB #19

    View full-size slide

  75. Q&A
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)

    View full-size slide

  76. PWAs are now installable, offline-capable and can receive push
    notifications on all relevant platforms
    Google, Microsoft and Apple are aligned on installable web applications
    Project Fugu unlocks more and more capabilities for the web in a secure,
    privacy-preserving manner
    Big apps like Photoshop and Visual Studio Code prove that the
    application model works
    Write your apps once, run them anywhere!
    Progressive Web Apps
    für Desktop und Mobile mit Angular (Hands-on)
    Summary

    View full-size slide

  77. Thank you
    for your kind attention!
    Christian Liebel
    @christianliebel
    [email protected]

    View full-size slide