From 9b94e85203f49a5152aba1fcf79a50b05bcf8943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cipriani=20Bandarra?= <andreban@google.com> Date: Wed, 10 Feb 2021 11:19:17 +0000 Subject: [PATCH] Fixes Web Share for both text/plain and files (#458) - When the shareTarget element contains both text/url/title and the files element, add "text/plain" and the mime-types from the files. --- packages/core/src/lib/TwaGenerator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/lib/TwaGenerator.ts b/packages/core/src/lib/TwaGenerator.ts index 53f7c3f8..93b8427a 100644 --- a/packages/core/src/lib/TwaGenerator.ts +++ b/packages/core/src/lib/TwaGenerator.ts @@ -344,13 +344,17 @@ export class TwaGenerator { mimeTypes: [], }; + if (twaManifest.shareTarget?.params?.url || + twaManifest.shareTarget?.params?.title || + twaManifest.shareTarget?.params?.text) { + shareTargetIntentFilter.mimeTypes.push('text/plain'); + } + if (twaManifest.shareTarget?.params?.files) { shareTargetIntentFilter.actions.push('android.intent.action.SEND_MULTIPLE'); for (const file of twaManifest.shareTarget.params.files) { file.accept.forEach((accept) => shareTargetIntentFilter.mimeTypes.push(accept)); } - } else { - shareTargetIntentFilter.mimeTypes.push('text/plain'); } return shareTargetIntentFilter; }