Skip to content

Commit

Permalink
Fixes Web Share for both text/plain and files (#458)
Browse files Browse the repository at this point in the history
- When the shareTarget element contains both text/url/title and
  the files element, add "text/plain" and the mime-types from
  the files.
  • Loading branch information
andreban authored Feb 10, 2021
1 parent 86cee84 commit 9b94e85
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/lib/TwaGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9b94e85

Please sign in to comment.