Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PWAで共有機能を実装する / pwa-web-share-api
Search
Yuhei FUJITA
December 15, 2021
Programming
940
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PWAで共有機能を実装する / pwa-web-share-api
Yuhei FUJITA
December 15, 2021
More Decks by Yuhei FUJITA
See All by Yuhei FUJITA
闇鍋VS Codeをプロファイル機能できれいにする / yami-nabe-vscode
yuhei_fujita
7
1.8k
GitHubとVitePressによる 開発ドキュメント運用 / escape-document-death
yuhei_fujita
3
550
進化したWeb技術でPWAをネイティブアプリに近づける / frontend-conf-2023
yuhei_fujita
6
4.9k
ChatGPTの機能を フル活用してChatGPTを 理想の彼女Botにする / nyanju-1st
yuhei_fujita
4
5.4k
GitHub ActionsとDeployGateで始めるAndroidアプリのCICD
yuhei_fujita
2
1.6k
手動テストの運用を GASで自動化した話 / gas-manage-test-operation
yuhei_fujita
1
780
開発ドキュメントの管理・閲覧に VitePress を使ってみて感じた良かった点と注意点 / document-with-vitepress
yuhei_fujita
1
1.7k
Other Decks in Programming
See All in Programming
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
350
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
360
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
730
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
190
Jetpack Compose Mechanisms
skydoves
2
340
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
620
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
270
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
660
R8 の設定見直しでアプリサイズ削減
andpad
0
140
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
310
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
310
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
A Modern Web Designer's Workflow
chriscoyier
699
190k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
sira's awesome portfolio website redesign presentation
elsirapls
0
440
Typedesign – Prime Four
hannesfritz
42
3.2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Transcript
PWAで共有機能を実装する Yuhei FUJITA
自己紹介 名前:Yuhei FUJITA Twitter:@Yuhei_FUJITA 生息地:東京 趣味:フィルムカメラ・コーヒー屋巡り よく使う言語:TypeScript・Kotlin・Python よく使うフレームワーク:Vue.js・Django・Laravel お仕事:Android・Frontend・Backend
PWAでも共有機能を実装したい
共有といっても2つある 他のアプリに 共有する Web Share API 他のアプリから 共有される Web Share
Target API
Web Share API
Webからコンテンツを共有するためのAPI ←これをWebアプリから開けるようになる • ブラウザ自体の共有機能ではなく JavaScriptから共有メニューを開ける • 任意のコンテンツ(テキスト)を共有できる • PWAでなくても利用可能 •
主なモバイルブラウザやMac Safariで利用可能
navigator.share()に渡すデータ ブラウザがnavigator.share()を サポートしているかチェック navigator.share()は Promise<void>を返すので awaitをつける navigator.share()を呼び出して共有 https://developer.mozilla.org/ja/docs/Web/API/Navigator/share
Web Share API Level 2ではメディアコンテンツ対応 共有したい画像などを File[]として渡す ※使えるのはAndroid Chromeなど 一部のブラウザのみ
https://chromestatus.com/feature/4777349178458112
Web Share Target API
PWAを共有先に追加するAPI ←ここにインストールしたPWAが表示される • manifest.jsonに定義することで有効になる • GET/POSTで受け取れるものなら受け取れる • Safariは残念ながら非対応(いつものこと) • ネイティブアプリと違うのは複数設定はできない
渡されるPath HTTP Method (GET or POST) 渡される情報の定義 GETの場合はqueryとして渡される Web Share
Target APIの設定 manifest.jsonに設定内容を定義 例:GET /foo?title=aaa&text=bbb&url=ccc https://web.dev/web-share-target/
None
Advent Calendar 2021でも書いてます! ←ココ https://qiita.com/advent-calendar/2021/pwa
参考文献 • Navigator.share() - Web API | MDN ◦ https://developer.mozilla.org/ja/docs/Web/API/Navigator/share
• Web Share API Level 2 - Chrome Platform Status ◦ https://chromestatus.com/feature/4777349178458112 • Receiving shared data with the Web Share Target API ◦ https://web.dev/web-share-target/