Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing a PDF file with @capacitor/share works on some apps but only passes text if you select WhatsApp #530

Closed
mattwilson1024 opened this issue Jul 26, 2021 · 4 comments 路 Fixed by #816

Comments

@mattwilson1024
Copy link

Bug Report

Plugin(s)

@capacitor/share v1.0.3

Capacitor Version

馃拪   Capacitor Doctor  馃拪

Latest Dependencies:

  @capacitor/cli: 3.1.2
  @capacitor/core: 3.1.2
  @capacitor/android: 3.1.2
  @capacitor/ios: 3.1.2

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 3.1.2
  @capacitor/android: 3.1.2
  @capacitor/core: 3.1.2

[success] Android looking great! 馃憣

Platform(s)

Android (tested on version 10)

Current Behavior

If you create a PDF file, write it to storage using @capacitor/filesystem and then pass the URI (e.g. "file://" URI) of the newly created file to @capacitor/share, then it works with some apps (e.g. Gmail, Google Drive) and you get the file as an attachment.

However if you select a WhatsApp conversation, then it only shows the text, not the PDF file itself. This would not be useful in my use-case (the PDF is important but the text is not), and I think it would be confusing for users that they can share the PDF file to some apps but not others.

Example:

await Share.share({
  title: 'See cool stuff',
  text: 'Really awesome thing you need to see right meow',
  url: result.uri,     // a "file://..." uri
  dialogTitle: 'Share with buddies',
});

Expected Behavior

I would have expected WhatsApp to receive the PDF file and display it in the conversation, just as Gmail receives the PDF and adds it as an email attachment.

At first I wasn't sure if this was just a limitation with WhatsApp itself but if I open up the PDF in the mobile Microsoft Office app and press the share button in there, it does successfully pass the file through to WhatsApp and it shows up in the conversation, so that suggests that WhatsApp is capable of receiving and displaying PDFs via an Android Intent or some other mechanism.

Code Reproduction

I've created an example app to demonstrate the problem here: https://github.com/mattwilson1024/support-ticket-capacitor-share.

See src/app/home/home.page.ts to see how I wrote the file and tried to share it.

Running this on an Android device, pressing the button in the example app's home page and choosing a WhatsApp conversation, you only get the text ("Really awesome thing you need to see right meow") but not the attached PDF file.

Other Technical Details

I have only tested this on Android as I don't have an iPhone to test with right now so not sure if this is specific to the Android platform or if it also applies on iOS.

@mirko49
Copy link

mirko49 commented Sep 7, 2021

I have the same issue.
For technical details I confirm that in iPhones it works as expected, Also it works in Android 9 too

@piyushnh
Copy link

I'm facing the same issue, on android 11

@mattwilson1024
Copy link
Author

Just to follow up, I can confirm that I've just updated and it's working great now. Thanks!

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants