readium / r2-testapp-swift

BSD 3-Clause "New" or "Revised" License
146 stars 38 forks source link

LCP: open from Files does not work anymore #263

Closed llemeurfr closed 4 years ago

llemeurfr commented 5 years ago

One cannot anymore import a license in the app by selecting it in the Files app and Share with R2 Reader.

llemeurfr commented 5 years ago

The message is of type: couldn't be moved because you don't have permission to access "Documents".

llemeurfr commented 4 years ago

I still see this issue with a license generated from my local server and shared on iCloud. The message is: Error while importing the publication: The file "xxxx.lcpl" couldn't be opened because there is no such file.

The same license is correctly handled if I import the license from the "+" button inside the app. Funny think is that if I do the same with a license corresponding to content in a remote server (e.g. the front-prod sandbox server) I have no problem importing the publication via File / share.

mickael-menu-mantano commented 4 years ago

I believe this is actually a bug in the Files app. Basically what's happening is that Files sends the local path to our app regardless of whether the file is downloaded or not (small cloud icon overlay). So if the file we try to open is not already on the device, our app can't read it.

I did find a workaround, by setting LSSupportsOpeningDocumentsInPlace to NO in the Info.plist of the app. This forces Files to first download the file, and then copy it in our app's sandbox. However to do that I had to remove UISupportsDocumentBrowser=YES, because it implicitely sets LSSupportsOpeningDocumentsInPlace to YES. Since we are not using UIDocumentBrowserViewController in the app, it's probably fine.

On a side note, after upgrading to iOS 13 to check if the issue was fixed in Files, Readium was not recognized for LCPL files anymore from the Files app. Adding a new Document Type in the app with exactly the same parameters but a different extension worked as intended. I can't explain it and didn't find a way to reset the shared Document Types so far.

HadrienGardeur commented 4 years ago

@mickael-menu this is a known issue with iOS 13 that almost all apps are facing right now.

I secretly hoped that Apple would fix it, but so far it hasn't been the case, even with 13.2.

mickael-menu-mantano commented 4 years ago

I guess they are too busy fixing SwiftUI... 😬

llemeurfr commented 4 years ago

Does closing means that lcpl files are now recognized again in Files?

aferditamuriqi commented 4 years ago

@llemeurfr the issue was tagged to the PR, so this would mean it should work now again, i haven't gotten a chance to test all scenarios, but a new testflight is on its way