Rocket.Chat.ReactNative icon indicating copy to clipboard operation
Rocket.Chat.ReactNative copied to clipboard

Can't open PDF attachments on android

Open racquetmaster opened this issue 3 years ago • 12 comments

Description:

When I open a pdf, it sends me to the play store searching for a reader when there are already apps capable of handling pdfs installed.

Environment Information:

  • Rocket.Chat Server Version: 4.8
  • Rocket.Chat App Version: 4.32.0.35745
  • Device Name: Pixel 5a
  • OS Version: Android 13

Steps to reproduce:

  1. Click on Pdf attachment

Expected behavior:

Open with app used for pdf (or prompt if one wasn't already selected)

Actual behavior:

Opens google play with application/pdf in search field. It does download the file and when I open the file using the file app, it opens correctly.

Additional context:

Pdfs open fine using other applications on this device.

racquetmaster avatar Dec 02 '22 23:12 racquetmaster

hello @racquetmaster tried to reproduce ur issue find out things are working fine app was asking for inbuilt supported apps for pdfs WhatsApp Image 2022-12-09 at 2 00 21 PM

Misterr-H avatar Dec 09 '22 08:12 Misterr-H

https://user-images.githubusercontent.com/17813806/206906620-00822a78-e6c9-4a5d-a595-4cb011a32279.mp4

Here is a screen recording of the issue.

racquetmaster avatar Dec 11 '22 13:12 racquetmaster

It is also referenced in this comment.

https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/2824#issuecomment-1124153897

racquetmaster avatar Dec 11 '22 13:12 racquetmaster

@racquetmaster What happens if you install one of those PDF apps and try again?

diegolmello avatar Dec 12 '22 13:12 diegolmello

Unfortunately, it does the exact same thing.

I just tried it again after installing the first app on that list (adobe) and it still links to the Google play store. I do already have other apps that can handle pdfs (Google drive). Even though it takes me to the play store, a notification shows that it downloaded. If I click on that notification, it does open using my default PDF viewer. So it is downloading the file. The open instruction just isn't working properly.

Thanks for everyone's work to make this better!

racquetmaster avatar Dec 12 '22 14:12 racquetmaster

I see. It could be a Pixel specific issue.

Do you have a OS default app for PDFs? When you try to open PDF from Files app, for example. Does it prompts like this? https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/4726#issuecomment-1344003880

diegolmello avatar Dec 12 '22 14:12 diegolmello

Originally I did not have a default PDF app set and I was getting the issue as described. I set a default app to see if that would change anything and it did not.

racquetmaster avatar Dec 13 '22 03:12 racquetmaster

Same problem here, and I cannot set a default app for PDF in android apparently. Anyone else has a solution for this?

Taapo avatar Jan 16 '23 16:01 Taapo

We need to search for alternatives then. It's working on all Android devices we have here.

diegolmello avatar Jan 20 '23 18:01 diegolmello

We acknowledge the problem, but we don't expect to allocate capacity to resolve the issue in a near future

milton-rucks avatar Jan 27 '23 17:01 milton-rucks

@diegolmello @racquetmaster @milton-rucks Is this issue still open ? what if we can integrate react-pdf-viewer to view pdfs inside mobile application itself.

sahildev-ambula avatar Dec 01 '23 05:12 sahildev-ambula

@diegolmello @racquetmaster @milton-rucks Is this issue still open ? what if we can integrate react-pdf-viewer to view pdfs inside mobile application itself.

Yes, it is open, but the best option would be to open it in the specific PDF application. As the issue complains.

dnlsilva avatar Dec 01 '23 10:12 dnlsilva

@diegolmello @racquetmaster @milton-rucks

I'm planning to implement a native module that:

Checks for Installed PDF Viewers:

On Android: Uses PackageManager to verify if a compatible PDF viewer exists.

On iOS: Uses UIDocumentInteractionController to check availability.

Open PDF with Available Viewer:

If a viewer is found, the app will open the PDF using an Intent (Android) or a preview controller (iOS).

Handle Missing Viewer Gracefully:

If no viewer is available, the user will be shown a message recommending them to install a suitable application.

The objective is to eliminate unnecessary redirections to the Play Store and enhance the user experience by directly launching the PDF viewer if it's installed.

Could you kindly review this approach and provide your feedback? Additionally, if you have suggestions for improving this solution or making it more efficient, I would greatly appreciate your guidance.

JASIM0021 avatar Mar 23 '25 14:03 JASIM0021

@JASIM0021 Sure! I'll be happy to review your contribution!

diegolmello avatar Mar 24 '25 16:03 diegolmello

@JASIM0021 Quick tip: The way to go when you open a PR fixing an issue is to write Closes #${ISSUE_NUMBER} on your PR description. With that, Github automatically closes the issue when the PR is merged.

This issue no longer occurs after merging this https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/6299.

No reason to write this comment.

diegolmello avatar Apr 11 '25 13:04 diegolmello