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

PWA-Workshop: PWAs für moderne Cross-Platform-Lösungen mit Blazor

PWA-Workshop: PWAs für moderne Cross-Platform-Lösungen mit Blazor

Stellen Sie sich vor, Sie schreiben Ihre moderne Businessanwendung genau einmal – und sie läuft auf Windows, macOS, Linux, Android, iOS und im Browser. Diese Anwendungen werden per Fingertippen aus dem Browser auf dem Gerät installiert und funktionieren auch dann, wenn das WiFi im Zug gerade mal wieder nicht funktioniert. Das klingt fantastisch? Dank Progressive Web Apps (PWA) wird all das Wirklichkeit. Mit Hilfe moderner Webtechnologien wird aus einer Webanwendung eine App, die einer nativen App in nichts nachsteht. In diesem Workshop zeigen wir anhand eines durchgängigen Beispiels die Grundlagen der PWA-Entwicklung mit Microsofts Single Page App Framework Blazor, bei denen Sie aktiv mitentwickeln können. Jede(r) geht mit einer PWA nach Hause!

Christian Liebel

October 14, 2022
Tweet

More Decks by Christian Liebel

Other Decks in Programming

Transcript

  1. Progressive Web Apps für moderne Cross-Platform-Lösungen mit Blazor Christian Liebel

    Patrick Jahr @christianliebel @jahr_patrick Consultant Consultant
  2. Feel free to ask questions anytime! Your instructors für moderne

    Cross-Platform-Lösungen mit Blazor Progressive Web Apps Patrick Jahr Christian Liebel
  3. 08:30–10:00 Block 1 10:00–10:30 Break 10:30–12:00 Block 2 12:00–13:00 Break

    13:00–14:30 Block 3 14:30–15:00 Break 15:00–16:30 Block 4 Timetable für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  4. Proposal 08:30–10:00 Block 1 10:00–10:15 Break 10:15–12:00 Block 2 12:00–12:45

    Break 12:45–14:30 Block 3 14:30–14:45 Break 14:45–15:45 Block 4 Timetable für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  5. Things NOT to expect - Blueprint for PWA development -

    No AuthN/AuthZ - No 1:1 support 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 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  6. 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 Demo Use Case für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  7. (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 Demo Use Case für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  8. Setup complete? (.NET 6 SDK, Visual Studio 2022, Chrome or

    Edge, Git) Setup (1/2) LAB für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  9. 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+ Paint für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  10. Canvas Add a canvas element to Index.razor: <Canvas @ref="_canvas" width="600"

    height="480"></Canvas> Query the canvas element in Index.razor.cs: private Canvas? _canvas; Paint EX #1 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  11. Canvas 2D Context fillRect(x, y, width, height) strokeRect(x, y, width,

    height) beginPath() moveTo(x, y) lineTo(x, y) fill() stroke() Paint für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  12. Canvas 2D Context Get the 2D context and prepare the

    canvas in Index.razor.cs in the method OnAfterRenderAsync(bool firstRender): await using var context = await _canvas!.GetContext2DAsync(); await context.FillStyleAsync("white"); await context.FillRectAsync(0, 0, 600, 480); await context.FillStyleAsync("black"); Paint EX #2 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  13. Low-latency Rendering 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) für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  14. Low-latency Rendering Opt-in to low-latency rendering (Index.razor.cs): await using var

    context = await _canvas!.GetContext2DAsync(desynchronized: true); Paint EX #3 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  15. Pointer Events 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 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  16. Pointer Events Add event listeners (Index.razor): <Canvas #canvas width="600" height="480"

    @onpointerdown="OnPointerDown" @onpointerup="OnPointerUp" @onpointermove="OnPointerMove"> </Canvas> Paint EX #4 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  17. Pointer Events Add event listeners methods (Index.razor.cs): private async void

    OnPointerMove(PointerEventArgs args) { var currentPoint = new Point { X = (int)Math.Floor(args.OffsetX), Y = (int)Math.Floor(args.OffsetY) }; await context.FillRectAsync(currentPoint.X, currentPoint.Y, 2, 2); } Paint EX #4 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  18. Pointer Events Add event listeners methods (Index.razor.cs): private async void

    OnPointerDown(PointerEventArgs args) { if (_module != null && _canvas!.AdditionalAttributes.TryGetValue("id", out var id)) { await _module.InvokeVoidAsync("registerEvents", id, _selfReference); } _previousPoint = new Point { X = (int)Math.Floor(args.OffsetX), Y = (int)Math.Floor(args.OffsetY) }; } Paint EX #4 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  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 Paint für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  20. Bresenham Line Algorithm Update the method OnPointerMove() in Index.razor.cs: if

    (_previousPoint != null) { var currentPoint = new Point { X = (int)Math.Floor(args.OffsetX), Y = (int)Math.Floor(args.OffsetY) }; var points = _paintService.BrensenhamLine(_previousPoint.Value, currentPoint); await using var context = await _canvas.GetContext2DAsync(); foreach (var point in points) { await context.FillRectAsync(point.X, point.Y, 2, 2); } _previousPoint = currentPoint; } Paint EX #5 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  21. 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: <input type="color"> Paint für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  22. Color Selection 1. In Index.razor, add the following input to

    the <nav> node: <input type="color" @onchange="OnColorChange" /> 2. In Index.razor.cs, add the following code in the method OnColorChange(): await using var context = await _canvas!.GetContext2DAsync(); await context.FillStyleAsync(args.Value?.ToString()); Paint EX #6 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  23. Responsive Linkable Discoverable Installable App-like Connectivity Independent Fresh Safe Re-engageable

    Progressive für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  24. 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. PWA für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  25. manifest.webmanifest { "short_name": "Paint", "name": "Paint Workshop", "theme_color": "white", "icons":

    [{ "src": "icon.png", "sizes": "512x512" }], "start_url": "./", "display": "standalone", "shortcuts": [/* … */] } PWA Names Icons Display Mode Shortcuts Start URL Theme color (status bar/window bar) für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  26. Manifest Display Modes PWA browser minimal-ui standalone fullscreen für moderne

    Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  27. Manifest Icon Purposes (any) any context (e.g. app icon) monochrome

    different color requirements (at risk) maskable user agent masks icon as required PWA Safe Zone Windows iOS Android für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  28. Blazor Support The Blazor PWA template adds a web app

    manifest and service worker support Progressive Web Apps für moderne Cross-Platform-Lösungen mit Blazor PWA
  29. Web App Manifest 1. Update the file wwwroot/manifest.json and set:

    a) name and short_name to values of your choice b) theme_color to #000080 and background_color to #808080 2. In index.html, set theme_color to #000080 as well. 3. Run dotnet run 4. Test manifest in DevTools: F12 > Application > Manifest PWA EX #7 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  30. Manifest Shortcuts 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 and Edge for Windows für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  31. Web App Manifest 1. In wwwroot/manifest.json, add (at least) the

    following shortcut: "shortcuts": [{ "name": "About Paint", "short_name": "About", "description": "Show information about Paint", "url": "./", "icons": [{ "src": "icon-512.png", "sizes": "512x512" }] }], 2. Test in DevTools: F12 > Application > Manifest PWA EX #8 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  32. Web App Manifest – Installability Criteria Web App is not

    already installed User clicked the page at least once and had it open for at least 30 seconds (at any time) 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 Served over HTTPS Has a registered service worker with a fetch event handler https://web.dev/install-criteria/#criteria PWA für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  33. Service Worker JavaScript snippet 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) PWA für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  34. Service Worker PWA Service Worker Internet Website HTML/JS Cache fetch

    für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  35. Blazor Service Worker The Blazor PWA template includes a custom

    service worker implementation All Blazor assets are precached by default Service Worker behavior can be modified (e.g., for push) à maximum flexibility PWA für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  36. Service Worker 1. Start application with dotnet run or with

    Visual Studio 2. Test in DevTools: F12 > Application > Service Worker 3. Install the app: Address Bar > Install PWA EX #9 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  37. 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 Support coming to Safari for macOS with Ventura, iOS and iPadOS in 2023 Progressive Web Apps für moderne Cross-Platform-Lösungen mit Blazor PWA
  38. Service Worker Debugging More information on installed service workers can

    be found on • about://serviceworker- internals (Google Chrome) • about:serviceworkers (Mozilla Firefox) PWA für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  39. Lighthouse 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 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  40. 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 “Generate report” PWA EX #10 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  41. Project Fugu Capabilities »Let’s bring the web back – API

    by API« Thomas Steiner, Google für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  42. Capabilities Contacts Picker Screen Wake Lock API File System Access

    API Shape Detection API für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  43. Fugu Process – Write an Explainer (https://github.com/WICG/native-file- system/blob/master/EXPLAINER.md) – Discuss

    capability with developers, browser vendors, standard orgs – Iterate – Compile a design document – W3C TAG Review (https://github.com/w3ctag/design- reviews/issues/390) – Formal spec within Web Incubator Community Group (WICG, https://wicg.github.io/native-file-system/) Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  44. Fugu Process – Implementation in Chromium – Launches behind a

    flag (about://flags/#enable-experimental-web- platform-features) – Origin Trial (https://developers.chrome.com/origintrials/) – Transfer to W3C Working Group + Recommendation? Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  45. 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 Chromium- based browsers on desktop Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  46. File System Access API 1. Add the following buttons to

    the <nav> bar in Index.razor (before the color input): <button @onclick="OpenLocalFile">Open</button> <button @onclick="SaveFileLocal">Save</button> <button @onclick="Copy">Copy</button> <button @onclick="Paste">Paste</button> <button @onclick="Share">Share</button> Capabilities EX #11 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  47. File System Access API 2. Add the following lines at

    the top of Index.razor.cs: private static FilePickerAcceptType[] _acceptTypes = new FilePickerAcceptType[] { new FilePickerAcceptType { Accept = new Dictionary<string, string[]> { { "image/png", new[] {".png" } } }, Description = "PNG files" } }; Capabilities EX #11 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  48. File System Access API 3. Add the following lines at

    the top of Index.razor.cs: private SaveFilePickerOptionsStartInWellKnownDirectory _savePickerOptions = new SaveFilePickerOptionsStartInWellKnownDirectory { StartIn = WellKnownDirectory.Pictures, Types = _acceptTypes }; Capabilities EX #11 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  49. File System Access API 4. Add the following lines in

    the method SaveLocalFile() of Index.razor.cs: if (_fileHandle == null) { _fileHandle = await _fileSystemAccessService .ShowSaveFilePickerAsync(_savePickerOptions); } Capabilities EX #11 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  50. File System Access API 5. Add the following lines in

    the method SaveLocalFile() of Index.razor.cs: var writeable = await _fileHandle.CreateWritableAsync(); var image = await _imageService.GetImageDataAsync("canvas"); await writeable.WriteAsync(image); await writeable.CloseAsync(); await _fileHandle.JSReference.DisposeAsync(); _fileHandle = null; Capabilities EX #11 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  51. File System Access API 1. Add the following lines at

    the top of Index.razor.cs: private readonly OpenFilePickerOptionsStartInWellKnownDirectory _filePickerOptions = new OpenFilePickerOptionsStartInWellKnownDirectory { Multiple = false, StartIn = WellKnownDirectory.Pictures, Types = _acceptTypes }; Capabilities EX #12 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  52. File System Access API 2. Add the following code int

    the method OpenLocalFile() of Index.razor.cs: try { var fileHandles = await _fileSystemAccessService.ShowOpenFilePickerAsync(_filePickerOptions); _fileHandle = fileHandles.Single(); } catch (JSException ex) { Console.WriteLine(ex); } Capabilities EX #12 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  53. File System Access API 3. Add the following code int

    the method OpenLocalFile() of Index.razor.cs: finally { if (_fileHandle is not null) { var file = await _fileHandle.GetFileAsync(); await _imageService.OpenFileAccessAsync(file.JSReference); await using var context = await _canvas!.GetContext2DAsync(); await context.DrawImageAsync("image", 0, 0); } } Capabilities EX #12 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  54. 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 Chromium- based browsers and Safari Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  55. Async Clipboard API Add the following code in the method

    Copy() of Index.razor.cs: var imagePromise = _asyncClipboardService.GetObjectReference( _module!, "getCanvasBlob", "canvas"); var clipboardItem = new ClipboardItem( new Dictionary<string,IJSObjectReference> { { "image/png", imagePromise } }); await _asyncClipboardService.WriteAsync( new[] { clipboardItem } ); Capabilities EX #13 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  56. Async Clipboard API Add the following code in the method

    Paste() of Index.razor.cs: var clipboardItems = await _asyncClipboardService.ReadAsync(); var pngItem = clipboardItems .FirstOrDefault(c => c.Types.Contains("image/png")); if (pngItem is not null) { var blob = await pngItem.GetTypeAsync("image/png"); await _imageService.OpenFileAccessAsync(blob); await using var context = await _canvas!.GetContext2DAsync(); await context.DrawImageAsync("image", 0, 0); } Capabilities EX #14 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  57. 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 on Windows and Chrome OS, Edge, Safari Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  58. Web Share API Add the following code in the share()

    method in the Index.razor.cs: var fileReference = await _imageService.GenerateFileReferenceAsync( await _canvas!.ToDataURLAsync()); await _shareService.ShareAsync( new WebShareDataModel { Files = new[] { fileReference } }); Capabilities EX #15 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  59. File System 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 Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  60. File System Handling API 1. Add the following property to

    your manifest (wwwroot/manifest.json): "file_handlers": [{ "action": "./", "accept": { "image/png": [".png"] } }] Capabilities EX #16 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  61. File System Handling API 2. Add the following code to

    the Index.razor.js file at row 23: if ('launchQueue' in window) { window.launchQueue.setConsumer(async params => { const [handle] = params.files; if (handle) { const file = await handle.getFile(); await createImageElement(file); component.invokeMethodAsync('DrawImageAsync'); } }); } Capabilities EX #16 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  62. File System Handling API 3. Add the following code to

    method OnAfterRenderAsync in the Index.razor.cs file: _selfReference = DotNetObjectReference.Create(this); if (_module == null) { _module = await JS.InvokeAsync<IJSObjectReference>("import", "./Pages/Index.razor.js"); } await _module.InvokeVoidAsync("initializeLaunchQueue", _selfReference); Capabilities EX #16 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  63. File System Handling API 4. Add the following code to

    the method DrawImageAsync in the Index.razor.cs file: [JSInvokable] public async Task DrawImageAsync() { await using var context = await _canvas!.GetContext2DAsync(); await context.DrawImageAsync("image", 0, 0); } Capabilities EX #16 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  64. 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 Capabilities für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  65. 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 Enhancement für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  66. 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 Enhancement für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  67. Disabling unsupported features In Index.razor.cs, hide the buttons in case

    the respective API does not exist, e.g.: _fileSystemAccessSupported = await _fileSystemAccessService.IsSupported(); And hide the buttons which are not supported in the Index.razor, e.g.: @if(_fileSystemAccessSupported) { <button @onclick="OpenLocalFile">Open</button> <button @onclick="SaveFileLocal">Save</button> } else { <InputFile OnChange="OpenFile"></InputFile> <button @onclick="SaveFile">Download</button> } Progressive Enhancement EX #17 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  68. Disabling unsupported features 1. Copy: await _asyncClipboardService.IsSupportedAsync(); 2. Paste: await

    _asyncClipboardService.IsSupportedAsync(); 3. Share: await _shareService.IsSupportedAsync(); Progressive Enhancement EX #17 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  69. Disabling unsupported features Add the following code to the method

    OnInitializedAsync in the Index.razor.cs file: _fileSystemAccessSupported = await _fileSystemAccessService.IsSupported(); _clipboardApiSupported = await _asyncClipboardService.IsSupportedAsync(); _shareApiSupported = await _shareService.IsSupportedAsync(); Progressive Enhancement EX #17 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  70. Disabling unsupported features Replace the following code to the Index.razor

    file: <button @onclick="Copy" disabled="@(!_clipboardApiSupported)">Copy</button> <button @onclick="Paste" disabled="@(!_clipboardApiSupported)">Paste</button> <button @onclick="Share" disabled="@(!_shareApiSupported)">Share</button> Progressive Enhancement EX #17 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  71. Providing an alternative implementation If the feature are not supported,

    fall back to the following code for the SaveFile() Method: await _imageService.DownloadAsync(await _canvas!.ToDataURLAsync()); Progressive Enhancement EX #18 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  72. Providing an alternative implementation If the feature are not supported,

    fall back to the following code for the OpenFile() Method: await using var context = await _canvas!.GetContext2DAsync(); await _imageService.OpenAsync(args.File.OpenReadStream(1024 * 15 * 1000)); await context.DrawImageAsync("image", 0, 0); Progressive Enhancement EX #19 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  73. Deployment Electron/Capacitor JS HTML CSS .ipa .exe .app ELF .apk

    .appx Single-Page Application Capacitor Electron für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  74. (Simplified) Store Deployments https://example.com .appx .apk Server Microsoft Store Play

    Store Source Files für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  75. Run app on your device https://ngrok.com/download ngrok http {{port}} EX

    #20 für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  76. Implement great productivity, enterprise, … applications that run just fine

    in the browser Improve the experience by allowing users to install your app and run it offline Add Fugu capabilities for an even deeper integration with the operating system Ensure that users of older or less powerful browsers can still use the app Let’s build great apps for the web! Summary für moderne Cross-Platform-Lösungen mit Blazor Progressive Web Apps
  77. Thank you for your kind attention! Christian Liebel @christianliebel [email protected]

    https://www.thinktecture.com/ueber-uns/karriere/ Patrick Jahr @jahr_patrick [email protected]