Can't open PDF attachments on android
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:
- 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.
hello @racquetmaster
tried to reproduce ur issue
find out things are working fine
app was asking for inbuilt supported apps for pdfs

https://user-images.githubusercontent.com/17813806/206906620-00822a78-e6c9-4a5d-a595-4cb011a32279.mp4
Here is a screen recording of the issue.
It is also referenced in this comment.
https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/2824#issuecomment-1124153897
@racquetmaster What happens if you install one of those PDF apps and try again?
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!
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
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.
Same problem here, and I cannot set a default app for PDF in android apparently. Anyone else has a solution for this?
We need to search for alternatives then. It's working on all Android devices we have here.
We acknowledge the problem, but we don't expect to allocate capacity to resolve the issue in a near future
@diegolmello @racquetmaster @milton-rucks Is this issue still open ? what if we can integrate react-pdf-viewer to view pdfs inside mobile application itself.
@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.
@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 Sure! I'll be happy to review your contribution!
@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.