Plugin Request: Share Files or Data
Web Share API is not available for android https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API and shell open does not work with file paths on mobile.
We need a way to make the mobile app share files or data.
Hi @ecmel , I would try to implement this
Here we only speak about sending data rigth, not be the target ?
The downside of Android's intent is the api can't be 1-1 to the web api, and the guest js should be the most platform agnostic I believe
PS: there is no way to ensure the share worked, there is no standard about that, some application respond when the handling of the file is ok, some other when the file is valid, some other only respond with errror when it's invalid... And most app never respond 😅🥹 (but accept without any issue the file)
Hi @flapili thank you for your response, yes I am speaking about sending data not target. Specifically I need to share a pdf file stored in app data dir and view it in system's default pdf viewer or send by e-mail etc. For MacOS the shell open api works very well, for iOS web share api some what works but for android I could not find a way.
I'll try to take a look, but I'm clueless about path, I only found example when the file is sent as bytes not path
What kind of spec / DX / final API would you like to have ?
EDIT: found https://developer.android.com/reference/android/content/ContentUris
In fact https://beta.tauri.app/reference/javascript/shell/#open function works on desktop very well, on android I get the following error. This may be a purely device permission issue and may be easy to fix.
@flapili While searching for a solution I bumped into https://stackoverflow.com/questions/42213316/how-to-share-file-in-android Not tried yet but can be a simple solution for file sharing.
Also, the following capacitor plugins can be relevant:
https://github.com/ionic-team/capacitor-plugins/tree/main/share https://github.com/capacitor-community/file-opener
I have made a plugin for viewing files on mobile similar to shell open on desktop: https://github.com/ecmel/tauri-plugin-view
I have made a plugin for viewing files on mobile similar to shell open on desktop: https://github.com/ecmel/tauri-plugin-view
@ecmel Thank you for creating this plugin! 🙌 I’ve been struggling to find a solution for viewing files on mobile, and your plugin worked perfectly for my use case. It literally saved my app (https://apps.apple.com/in/app/simple-invoice-bill-maker/id6737187790) — couldn’t have shipped without it!
I found another plugin that offers text sharing on both Android and iOS: https://github.com/buildyourwebapp/tauri-plugin-sharesheet
There is also a fork that adds file sharing and some tests: https://github.com/rittme/tauri-plugin-sharesheet
The code looks pretty simple. It would be nice if such a plugin could become an official part of plugins-workspace.