diachedelic / capacitor-blob-writer

Capacitor plugin to write binary data to the filesystem
MIT License
132 stars 17 forks source link

[BUG][IOS] Can't write after coming back from background due to access control checks #53

Closed dragermrb closed 2 years ago

dragermrb commented 2 years ago

Bug Report

On IOS and capacitor4, can't write after coming back from background due to access control checks. This is the error reported on console:

[Error] Could not connect to the server.
[Error] Fetch API cannot load http://localhost:53869/var/mobile/Containers/Data/Application/F7A3241E-E154-4C7C-A360-9971CD09A1E3/Documents/demo_0.10861703844695692.pdf due to access control checks.
[Error] Failed to load resource: Could not connect to the server. (demo_0.10861703844695692.pdf, line 0)

Versions

Current Behavior

After putting the app in the background and turning off the screen for a few seconds, it is not possible to write files again.

Follow the steps below to reproduce the issue:

[Error] Could not connect to the server.
[Error] Fetch API cannot load http://localhost:53869/var/mobile/Containers/Data/Application/F7A3241E-E154-4C7C-A360-9971CD09A1E3/Documents/demo_0.10861703844695692.pdf due to access control checks.
[Error] Failed to load resource: Could not connect to the server. (demo_0.10861703844695692.pdf, line 0)

Code Reproduction

Sample app to reproduce de issue

https://github.com/dragermrb/app-sample-blob-writer

git clone git@github.com:dragermrb/app-sample-blob-writer.git
cd app-sample-blob-writer
npm install
npm run build
npx cap sync ios
diachedelic commented 2 years ago

What happens if you change this line to true? https://github.com/diachedelic/capacitor-blob-writer/blob/cb517d6c82920f90226ec07b6ddf6dfebc5c8f9d/ios/Plugin/Plugin.swift#L77

dragermrb commented 2 years ago

It's working!

diachedelic commented 2 years ago

I set that option to false to fix #49. What version of iOS are you using?

diachedelic commented 2 years ago

This should be fixed in v1.1.4, please test.

dragermrb commented 2 years ago

This should be fixed in v1.1.4, please test.

I am using iOS version 15.6.1.

Now it works fine with version v1.1.4.

Thanks!!