EternallLight / cordova-plugin-openwith-ios

A modified version of the Cordova iOS Share extension (cordova-plugin-openwith) by Jean-Christophe Hoelt for iOS. Supports receiving shared URLs, text and images as well as sharing several images at once.
https://web-mystery.com/
MIT License
28 stars 84 forks source link

The file couldn’t be opened because you don’t have permission to view it. #32

Open colinethrl opened 3 years ago

colinethrl commented 3 years ago

Hey there, I'm using this plugin to share photos from the photo gallery to my app, and although it works fine on emulator, it doesn't on real device.

On emulator, the image is stored in : file:///Users//Library/Developer/CoreSimulator/Devices/D5C7BC3D-F9FB-4444-BA30-DC11E32C066D/data/Media/PhotoData/OutgoingTemp/28D91F3B-21F7-4DBD-8FF6-F273EF068844/IMG_0002.JPG

And I can access it easily using the fileSystem.

But on real device the path looks like : file:///var/mobile/Media/PhotoData/OutgoingTemp/A535F1DB-4973-49D0-AE70-B05FDD65416A/IMG_1519.PNG

And when I do fileSystem.readFile() it returns this error :

{"errorMessage":"The file “IMG_1519.PNG” couldn’t be opened because you don’t have permission to view it.","message":"The file “IMG_1519.PNG” couldn’t be opened because you don’t have permission to view it."}

I tried copying it to another place, I have the same error. I tried adding

UIFileSharingEnabled LSSupportsOpeningDocumentsInPlace

to my Info.plist, no success either.

I even tried manually triggering the "access to Photo Library" permission pop up, but it doesn't seem to change anything.

I also have a place in my app where I use an input to access the Photo Library from the app so the user can pick a picture, and I can pick the one I've been trying to share. In this case, the Camera Plugin stores it in another temporary place, which is accessible : file:///private/var/mobile/Containers/Data/Application/F62330AB-847E-45B2-AA93-E7D85AAD1251/tmp/photo-1.jpg

How can I change the place where the extension places my picture data ? Or maybe there's a way of retrieving directly the base64 data from the plugin ?

Thanks !