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

Progressive Web Apps: Cross-Plattform-Apps auf Desktopniveau

Progressive Web Apps: Cross-Plattform-Apps auf Desktopniveau

Progressive Web Apps sind ein großartiges Anwendungsmodell auf Basis von Webtechnologien, das sich stetig weiterentwickelt hat: In den letzten Jahren kamen dank der Initiative Project Fugu viele neue Schnittstellen ins Web, die PWAs auf Desktopniveau gehoben haben. In diesem Jahr können PWAs endlich auch auf iPhones Pushbenachrichtigungen empfangen. Christian Liebel von Thinktecture stellt das Anwendungsmodell mit seinen Möglichkeiten und Einschränkungen vor. Schauen Sie also vorbei, wenn auch Sie Ihre App nur einmal schreiben und auf etlichen Geräten, Browsern und Betriebssystemen verwenden wollen!

Christian Liebel
PRO

May 10, 2023
Tweet

More Decks by Christian Liebel

Other Decks in Programming

Transcript

  1. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Christian Liebel
    @christianliebel
    Consultant

    View Slide

  2. Hello, it’s me.
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Christian Liebel
    Twitter:
    @christianliebel
    Email:
    christian.liebel
    @thinktecture.com
    Angular & PWA
    Slides:
    thinktecture.com
    /christian-liebel

    View Slide

  3. Cross-Plattform-Apps auf Desktopniveau
    Progressive Web Apps
    Responsive Linkable Discoverable Installable App-like
    Connectivity
    Independent
    Fresh Safe Re-engageable Progressive

    View Slide

  4. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Demo Use Case

    View Slide

  5. Cross-Plattform-Apps auf Desktopniveau
    Progressive Web Apps

    View Slide

  6. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Target Platforms
    PROGRESSIVE WEB APPS
    + cars, smart fridges, …

    View Slide

  7. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Web App
    Manifest
    Service
    Worker

    View Slide

  8. 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
    Cross-Plattform-Apps auf Desktopniveau
    PWA

    View Slide

  9. 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
    Cross-Plattform-Apps auf Desktopniveau
    PWA
    Names
    Icons
    Display Mode
    Shortcuts
    Start URL
    Theme color (status bar/window bar)

    View Slide

  10. Manifest Display Modes
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    PWA
    browser minimal-ui standalone fullscreen

    View Slide

  11. Manifest Icon Purposes
    (any)
    any context (e.g. app icon)
    monochrome
    different color requirements
    (at risk)
    maskable
    user agent masks icon as required
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    PWA
    Safe Zone
    Windows iOS Android

    View Slide

  12. Manifest Shortcuts
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    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 Slide

  13. Web App Manifest – Chrome Install Criteria
    1. Web App is not already installed
    2. Meets a user engagement heuristic (user has interacted and clicked
    with origin 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. A service worker is no longer required!
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    PWA
    https://web.dev/install-criteria/

    View Slide

  14. 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
    Cross-Plattform-Apps auf Desktopniveau
    PWA

    View Slide

  15. Service Worker
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    PWA
    Service
    Worker
    Internet
    Website
    HTML/JS
    Cache
    fetch

    View Slide

  16. 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
    Cross-Plattform-Apps auf Desktopniveau
    PWA

    View Slide

  17. 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
    Cross-Plattform-Apps auf Desktopniveau
    PWA

    View Slide

  18. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau

    View Slide

  19. Project Fugu
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities
    »Let’s bring the web
    back – API by API«
    Thomas Steiner, Google

    View Slide

  20. 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
    Cross-Plattform-Apps auf Desktopniveau
    Demo Use Case

    View Slide

  21. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities
    Contacts
    Picker
    Screen Wake
    Lock API
    File System
    Access API
    Shape
    Detection API

    View Slide

  22. Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities
    https://goo.gle/fugu-api-tracker

    View Slide

  23. Browser
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities
    navigator.share({ url: 'http://example.com' });
    ShareIntent DataTransferManager

    NSSharingServicePicker

    View Slide

  24. 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
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities

    View Slide

  25. Async Clipboard API
    Allows reading from/writing to
    the clipboard in an
    asynchronous manner (UI won’t
    freeze during long-running
    operations)
    Supported by Chrome, Edge
    and Safari and Firefox (plain-
    text only)
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities

    View Slide

  26. 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
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities

    View Slide

  27. File Handling API
    Register your PWA as a
    handler for file extensions
    New: Ability to define icons
    Requires installing the
    application first
    Declare supported extensions
    in Web App Manifest and add
    imperative code to your
    application logic
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Capabilities

    View Slide

  28. 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
    Cross-Plattform-Apps auf Desktopniveau
    Progressive Enhancement

    View Slide

  29. 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
    Cross-Plattform-Apps auf Desktopniveau
    Progressive Enhancement

    View Slide

  30. Isolated Web Apps
    – Packaged and signed for stronger security
    – Deployed through app stores, platform-
    specific bundles or installers
    – These additional trust anchors enable
    even more powerful APIs (e.g., Direct
    Sockets API) for IWAs
    – Still web-based, cross-platform and using
    open standards
    – But without the bloat of Electron
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Outlook

    View Slide

  31. Isolated Web Apps
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Outlook
    JS
    HTML CSS
    Enterprise
    Deploy
    App
    Store
    MSI,
    APK, …
    Signed Web Bundle
    Platform-
    specific

    View Slide

  32. Spotify
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Use Cases
    https://open.spotify.com/

    View Slide

  33. VS Code
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Use Cases
    https://vscode.dev/

    View Slide

  34. Photoshop
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Use Cases
    https://creativecloud.adobe.com/cc/photoshop

    View Slide

  35. Progressive Web Apps are now installable, offline-capable and able to
    receive push notifications on all operating systems
    New powerful APIs regularly ship with new releases of Chromium-based
    browsers
    If needed, you can still wrap your application in a platform-specific
    package à your investment in web apps always pays off!
    Let’s make the web a more capable platform!
    Progressive Web Apps
    Cross-Plattform-Apps auf Desktopniveau
    Summary

    View Slide

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

    View Slide