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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing PDF on IOS fails - file received but doesnot exists #141

Open
eliaweiss opened this issue Feb 18, 2021 · 11 comments
Open

Sharing PDF on IOS fails - file received but doesnot exists #141

eliaweiss opened this issue Feb 18, 2021 · 11 comments

Comments

@eliaweiss
Copy link

See more info in https://stackoverflow.com/questions/66256974/receive-share-file-intents-with-flutter-with-ios

When sharing a PDF file,
I was able to receive the file intent in the App but couldn't open the file:

print("$path, exist ${await io.File(path).exists()}");

I was able to print the path but the exists method return false

NOTE:

  1. works with no issues in android
  2. works with no issues in IOS when sharing an image
  3. only fails with files (PDF)
@LazyDave76
Copy link

LazyDave76 commented Feb 25, 2021

i've fired in a PR to try and fix this issue (#137)

try adding this to your pubspec.yaml file...

receive_sharing_intent:
    git:
      url: https://github.com/LazyDave76/receive_sharing_intent.git

@petodavid
Copy link

Hi, did you find a solution?

@petodavid
Copy link

i've fired in a PR to try and fix this issue (#137)

try adding this to your pubspec.yaml file...

receive_sharing_intent:
    git:
      url: https://github.com/LazyDave76/receive_sharing_intent.git

Does it fix PDF opening on iOS?

@yurisasc
Copy link

@petodavid Yes, that pull request fixes the PDF opening issue on iOS. If you see the changes, @LazyDave76 did a brilliant hack on removing the "file://" prefix on the file path.

@JanikoNaber
Copy link

Thank you @LazyDave76 for your fix. It works for me to open xml files. Is there any chance to see that fix in the next release on pub.dev?

@LazyDave76
Copy link

Thank you @LazyDave76 for your fix. It works for me to open xml files. Is there any chance to see that fix in the next release on pub.dev?

@KasemJaffer needs to merge this PR or copy my change into master before it will be released. Have asked for it to be merged again.

1 similar comment
@LazyDave76
Copy link

Thank you @LazyDave76 for your fix. It works for me to open xml files. Is there any chance to see that fix in the next release on pub.dev?

@KasemJaffer needs to merge this PR or copy my change into master before it will be released. Have asked for it to be merged again.

@mobikats
Copy link

mobikats commented Jun 2, 2022

I'm running into this now.

I have modified the SharedMediaFile path entry to remove the leading "file://", but it still can't open the PDF file.
Images etc work fine. I am sharing from the Files app on iOS.

flutter: FileSystemException: Cannot retrieve length of file, path = '/private/var/mobile/Containers/Shared/AppGroup/25C349AB-60EA-43FB-8C2E-F9B79F16530A/Screenshot%202021-03-22%20at%2014.13.28.pdf' (OS Error: No such file or directory, errno = 2)

Did you solve it in the end?

@eliaweiss
Copy link
Author

No I didn't

@mobikats
Copy link

mobikats commented Jun 2, 2022

Ok fixed it - it's because flutter doesn't like the path to be URL encoded, but iOS typically does (or this package does convert), so my workaround was to decode the URL encoding manually before trying to open the file, that works.
(Also remove the leading "file://" as mentioned above). Hope this helps somebody.

@gerken-tss
Copy link

@mobikats

Wow, this is amazingly ugly. Does this mean, I have to make two hard coded changes to the URL and also wrap this logic into a block that is only executed if the platform is iOS? And all this only for PDF files?
Damn, why is this plugin not maintained anymore? This sucks!

Have you also tried #37? Does it work? Or is it even worth changing to the share_handler package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants