Slide 1

Slide 1 text

Progressive Web Apps und Project Fugu Das nächste Level für Cross-Platform-Apps Christian Liebel Steffen Jahr @christianliebel @steffenjahr Consultant Consultant

Slide 2

Slide 2 text

Feel free to ask questions anytime! Your instructors Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu Steffen Jahr Christian Liebel

Slide 3

Slide 3 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 4

Slide 4 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 5

Slide 5 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 6

Slide 6 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 7

Slide 7 text

(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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 8

Slide 8 text

Setup complete? (Node.js, Google Chrome, Editor, Git) Setup (1/3) LAB Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 9

Slide 9 text

Optional Download and install Chrome Canary: https://www.google.com/intl/de/chrome/canary/ Setup (2/3) LAB Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 10

Slide 10 text

git clone https://github.com/thinktecture/basta- 2021-pwa-fugu.git cd basta-2021-pwa-fugu npm i npm start Setup (3/3) LAB Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 11

Slide 11 text

Paint PWA Capabilities Progressive Enhancement Agenda Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 12

Slide 12 text

Paint PWA Capabilities Progressive Enhancement Agenda Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 13

Slide 13 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 14

Slide 14 text

Canvas Add a canvas element to app.component.html (line 5): Query the canvas element in app.component.ts (line 10): @ViewChild('canvas') canvas: ElementRef; context: CanvasRenderingContext2D; Paint EX #1 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 15

Slide 15 text

Canvas 2D Context fillRect(x, y, width, height) strokeRect(x, y, width, height) beginPath() moveTo(x, y) lineTo(x, y) fill() stroke() Paint Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 16

Slide 16 text

Canvas 2D Context Get the 2D context and prepare the canvas in app.component.ts in the method ngAfterViewInit(): const canvas = this.canvas.nativeElement; const ctx = this.context = canvas.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = 'black'; Paint EX #2 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 17

Slide 17 text

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) Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 18

Slide 18 text

Low-latency Rendering Opt-in to low-latency rendering (app.component.ts): const ctx = this.context = canvas.getContext('2d', { desynchronized: true }); Paint EX #3 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 19

Slide 19 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 20

Slide 20 text

Pointer Events Add event listeners (app.component.html and app.component.ts): onPointerMove(event: PointerEvent): void { this.context.fillRect(~~event.offsetX, ~~event.offsetY, 2, 2); } Paint EX #4 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 21

Slide 21 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 22

Slide 22 text

Bresenham Line Algorithm Update the method onPointerMove() in app.component.ts: if (this.previousPoint) { const currentPoint = {x: ~~event.offsetX, y: ~~event.offsetY}; const points = this.paintService.bresenhamLine(this.previousPoint.x, this.previousPoint.y, currentPoint.x, currentPoint.y); for (const {x, y} of points) { this.context.fillRect(x, y, 2, 2); } this.previousPoint = currentPoint; } Paint EX #5 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 23

Slide 23 text

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: Paint Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 24

Slide 24 text

Color Selection 1. In app.component.html, add the following input to the node: 2. In app.component.ts, add the following code in the method colorChange(): this.context.fillStyle = $event.target.value; Paint EX #6 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 25

Slide 25 text

Paint PWA Capabilitie s Progressive Enhanceme nt Agenda Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 26

Slide 26 text

Responsive Linkable Discoverable Installable App-like Connectivity Independent Fresh Safe Re-engageable Progressive Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 27

Slide 27 text

Web App Manifest Service Worker Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 28

Slide 28 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 29

Slide 29 text

manifest.webmanifest { "short_name": "Paint", "name": "Paint Workshop", "theme_color": "white", "icons": [{ "src": "icon.png", "sizes": "512x512" }], "start_url": "/index.html", "display": "standalone", "shortcuts": [/* … */] } PWA Names Icons Display Mode Shortcuts Start URL Theme color (status bar/window bar) Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 30

Slide 30 text

Manifest Display Modes PWA browser minimal-ui standalone fullscreen Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 31

Slide 31 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 32

Slide 32 text

Web App Manifest 1. In your console, run: npx ng add @angular/pwa 2. Update the new file manifest.webmanifest and set: a) name and short_name to values of your choice b) theme_color to #000080 and background_color to #808080 3. In index.html, set theme_color to #000080 as well. 4. Run npm run start 5. Test manifest in DevTools: F12 > Application > Manifest PWA EX #7 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 33

Slide 33 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 34

Slide 34 text

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": "/index.html", "icons": [{ "src": "assets/icons/icon-512x512.png", "sizes": "512x512" }] }], 2. Test in DevTools: F12 > Application > Manifest PWA EX #8 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 35

Slide 35 text

Web App Manifest – Chrome Installability Signals Web App is not already installed Meets a user engagement heuristic (previously: user has interacted with domain for at least 30 seconds) 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 PWA Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 36

Slide 36 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 37

Slide 37 text

Service Worker PWA Service Worker Internet Website HTML/JS Cache fetch Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 38

Slide 38 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 39

Slide 39 text

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) PWA Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 40

Slide 40 text

Service Worker 1. Start build with npm run build 2. Go to dist folder: cd dist/basta-spring-2021-pwa-fugu 3. Start with npx lite-server 4. Test in DevTools: F12 > Application > Service Worker 5. Install the app: Address Bar > Install PWA EX #9 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 41

Slide 41 text

Push Notifications Just as native apps, PWAs can receive push notifications Combination of two technologies: Web Notifications and Push API (Not supported on Safari for macOS, iOS and iPadOS!) Progressive Web Apps und Project Fugu Das nächste Level für Cross-Platform-Apps PWA

Slide 42

Slide 42 text

Service Worker Debugging More information on installed service workers can be found on • about://serviceworker- internals (Google Chrome) • about:serviceworkers (Mozilla Firefox) PWA Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 43

Slide 43 text

Service Worker Debugging PWA Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 44

Slide 44 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 45

Slide 45 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 46

Slide 46 text

Paint PWA Capabilities Progressive Enhancement Agenda Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 47

Slide 47 text

Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 48

Slide 48 text

Project Fugu Capabilities »Let’s bring the web back – API by API« Thomas Steiner, Google Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 49

Slide 49 text

Capabilities Contacts Picker Screen Wake Lock API File System Access API Shape Detection API Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 50

Slide 50 text

Capabilities https://goo.gle/fugu-api-tracker Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 51

Slide 51 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 52

Slide 52 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 53

Slide 53 text

Capabilities navigator.share({ url: 'http://example.com' }); ShareIntent DataTransferManager … NSSharingServicePicker Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 54

Slide 54 text

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 Shipped with Google Chrome 86 Capabilities Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 55

Slide 55 text

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 Capabilities EX #11 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 56

Slide 56 text

File System Access API 2. Add the following lines at the top of app.component.ts: private fileOptions = { types: [{ description: 'PNG files', accept: {'image/png': ['.png']} }] }; Capabilities EX #11 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 57

Slide 57 text

File System Access API 3. Add the following lines in the method save() of app.component.ts: 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(); Capabilities EX #11 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 58

Slide 58 text

File System Access API Add the following code int the method open() of app.component.ts: 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); Capabilities EX #12 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 59

Slide 59 text

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 Capabilities Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 60

Slide 60 text

Async Clipboard API Add the following code in the method copy() of app.component.ts: const blob = await this.paintService.toBlob(this.canvas.nativeElement); await navigator.clipboard.write([ new ClipboardItem({[blob.type]: blob}) ]); Capabilities EX #13 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 61

Slide 61 text

Async Clipboard API Add the following code in the method paste() of app.component.ts: 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); } } } Capabilities EX #14 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 62

Slide 62 text

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) Files supported in Chrome on Android, Edge on Windows Capabilities Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 63

Slide 63 text

Web Share API Add the following code in the share() method in the app.component.ts: const blob = await this.paintService.toBlob(this.canvas.nativeElement); const file = new File([blob], 'untitled.png', {type: 'image/png'}); const item = {files: [file], title: 'untitled.png'}; if (navigator.canShare(item)) { await navigator.share(item); } Capabilities EX #15 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 64

Slide 64 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 65

Slide 65 text

File System Handling API 1. Enable the following flag in Chrome Canary and restart the browser: about://flags/#file-handling-api 2. Add the following property to your manifest (manifest.webmanifest): "file_handlers": [{ "action": "/index.html", "accept": { "image/png": [".png"] } }] Capabilities EX #16 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 66

Slide 66 text

File System Handling API 3. Add the following code to the bottom of the ngAfterViewInit() method of app.component.ts: if ('launchQueue' in window) { (window as any).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); } }); } 4. Re-generate Service Worker: npm run build -- --prod in main folder 5. Go to dist/basta-2021-pwa-fugu and run npx lite-server Capabilities EX #16 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 67

Slide 67 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 68

Slide 68 text

Paint PWA Capabilities Progressive Enhancement Agenda Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 69

Slide 69 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 70

Slide 70 text

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 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 71

Slide 71 text

Disabling unsupported features In app.component.ts, disable the buttons in case the respective API does not exist, e.g.: isClipboardDisabled = !('clipboard' in navigator && 'read' in navigator.clipboard); And update the buttons in the app.component.html with a [disabled] attribute, e.g.: Copy Progressive Enhancement EX #17 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 72

Slide 72 text

Disabling unsupported features 1. Open: window.showOpenFilePicker() 2. Save: window.showSaveFilePicker() 3. Copy: navigator.clipboard + navigator.clipboard.write() 4. Paste: navigator.clipboard + navigator.clipboard.read() 5. Share: navigator.canShare() Progressive Enhancement EX #17 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 73

Slide 73 text

Providing an alternative implementation 1. In app.component.ts in the method save(), test for the existence of the showSaveFilePicker() method on the navigator object. 2. If the method does not exist, fall back to the following code for save: const anchor = this.document.createElement('a'); const url = URL.createObjectURL(blob); anchor.href = url; anchor.download = ''; anchor.click(); URL.revokeObjectURL(url); Progressive Enhancement EX #18 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 74

Slide 74 text

Deployment Electron/Capacitor JS HTML CSS .ipa .exe .app ELF .apk .appx Single-Page Application Capacitor Electron Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 75

Slide 75 text

(Simplified) Store Deployments https://example.com .appx .apk Server Microsoft Store Play Store Source Files Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 76

Slide 76 text

Run app on your device https://ngrok.com/download ngrok http 3000 EX #19 Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 77

Slide 77 text

On the road to… Web-Payments neu gedacht Abrechnen mit der Payment Request API

Slide 78

Slide 78 text

Web-Payments neu gedacht Abrechnen mit der Payment Request API No app store, no money?

Slide 79

Slide 79 text

Web-Payments neu gedacht Abrechnen mit der Payment Request API Let’s use a checkout form!

Slide 80

Slide 80 text

Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 81

Slide 81 text

Progressive Enhancement if ('PaymentRequest' in window) { // use it… } else { // navigate to classic checkout form window.location.href = 'https://example.com/checkout'; } Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 82

Slide 82 text

API const request = new PaymentRequest(methodData, details, options); Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 83

Slide 83 text

API const methodData = [{ supportedMethods: 'basic-card', data: { supportedNetworks: ['visa'], supportedTypes: ['credit'] } }]; Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API Payment methods are not part of the spec!

Slide 84

Slide 84 text

API const details = { displayItems, total, shippingOptions }; Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 85

Slide 85 text

API displayItems: [{ label: '12-Monats-Abo', amount: {currency: 'EUR', value: '142.43'} }, { label: '7% MwSt.', amount: {currency: 'EUR', value: '9.97'} }], total: { label: 'Summe', amount: {currency: 'EUR', value: '152.40'} } Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 86

Slide 86 text

API const options = { requestPayerEmail: false, requestPayerName: false, requestPayerPhone: false, requestShipping: true }; Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 87

Slide 87 text

API const request = new PaymentRequest(methodData, details, options); request.canMakePayment(); Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 88

Slide 88 text

API const request = new PaymentRequest(methodData, details, options); request.show() .then(res => finishPurchase(res)) .then(res => res.complete('success')); Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 89

Slide 89 text

UI Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 90

Slide 90 text

Apple Pay Safari & macOS excusively support Payment Request API payments via Apple Pay Not supported by every major bank in Germany (yet) Apple Pay support requires additional configuration (e.g. server authentication, website verification) Payment Request API support is just a projection of the Apple Pay JS API Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API

Slide 91

Slide 91 text

Apple Pay Web-Payments neu gedacht Abrechnen mit der Payment Request API Payment Request API Demo: pwapraxis.liebel.io

Slide 92

Slide 92 text

Q&A Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 93

Slide 93 text

New powerful APIs regularly ship with new releases of Chromium-based browsers Some only add minor finishing touches, others enable whole application categories as productivity apps to finally make the shift to the web Some APIs already made their way into other browsers (e.g., Web Share) Fugu process makes sure that capabilities are implemented in a secure, privacy-preserving manner Let’s make the web a more capable platform! Summary Das nächste Level für Cross-Platform-Apps Progressive Web Apps und Project Fugu

Slide 94

Slide 94 text

Thank you for your kind attention! Christian Liebel Steffen Jahr @christianliebel @steffenjahr [email protected] [email protected]