Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PWAで共有機能を実装する / pwa-web-share-api
Search
Yuhei FUJITA
December 15, 2021
Programming
880
1
Share
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.7k
GitHubとVitePressによる 開発ドキュメント運用 / escape-document-death
yuhei_fujita
3
520
進化したWeb技術でPWAをネイティブアプリに近づける / frontend-conf-2023
yuhei_fujita
6
4.8k
ChatGPTの機能を フル活用してChatGPTを 理想の彼女Botにする / nyanju-1st
yuhei_fujita
4
5.2k
GitHub ActionsとDeployGateで始めるAndroidアプリのCICD
yuhei_fujita
2
1.5k
手動テストの運用を GASで自動化した話 / gas-manage-test-operation
yuhei_fujita
1
730
開発ドキュメントの管理・閲覧に VitePress を使ってみて感じた良かった点と注意点 / document-with-vitepress
yuhei_fujita
1
1.6k
Other Decks in Programming
See All in Programming
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
27
19k
JOAI2026 1st solution - heron0519 -
heron0519
0
170
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
第3木曜LT会 #28
tinykitten
PRO
0
120
when storing skills in S3 file
watany
3
1.2k
Building on Bluesky's AT Protocol with Ruby
mackuba
0
100
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.8k
実用!Hono RPC2026
yodaka
2
300
Explore CoroutineScope
tomoeng11
0
160
【26新卒研修】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
140
[RubyKaigi 2026] Require Hooks
palkan
1
290
Programming with a DJ Controller — not vibe coding
m_seki
3
780
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
800
Designing for Timeless Needs
cassininazir
0
220
Claude Code のすすめ
schroneko
67
220k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
540
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
180
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Making Projects Easy
brettharned
120
6.6k
Statistics for Hackers
jakevdp
799
230k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
340
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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/