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

running in background mode with iPhone locked #786

Open
csabbey opened this issue May 11, 2018 · 4 comments
Open

running in background mode with iPhone locked #786

csabbey opened this issue May 11, 2018 · 4 comments

Comments

@csabbey
Copy link

csabbey commented May 11, 2018

I have an iOS plugin for my project that tries to read from a database created by litehelpers/Cordova-sqlite-storage, and my plugin runs in background mode, sometimes while the phone is locked. I think SQLITE_OPEN_FILEPROTECTION_NONE has to be passed to SQLite when first opening (creating) the database for this to work.

It doesn't look like this is supported now - the sqlite3_open call in this project doesn't pass any flags. Could this be supported?

@brodycj
Copy link
Contributor

brodycj commented May 22, 2018

My apologies for the delay. SQLITE_OPERN_FILEPROTECTION flag does NOT seem to be supported by SQLite3 source code, not even by apple-osx branch ref: https://www.sqlite.org/src/timeline?n=100&r=apple-osx

This plugin does NOT use libsqlite3 packaged on iOS for multiple reasons. I think the best solution is to set NSProtectionKey to NSProtectionNone on opened/created database files and on default database directory (LocalDatabase directory). Thanks to @vzaidman for the suggestion in #264.

I would recommend this kind of a solution for similar problem with SQLCipher discussed in sqlcipher/sqlcipher#156 and ccgus/fmdb#262.

Marking this as wanted change for major release in June 2018 (#773) or another major release (#687).

@brodycj
Copy link
Contributor

brodycj commented Jun 11, 2018

Also related: sqlcipher/sqlcipher#274

@christocracy
Copy link

It seems you must provide NSFileProtectionNone to both the containing folder as well as the database filename.

NSFileManager *fileManager  = [NSFileManager defaultManager];
NSString* dbdir = [appDBPaths objectForKey:dblocation];

// Containing folder
[fileManager setAttributes:[NSDictionary dictionaryWithObject:NSFileProtectionNone forKey:NSFileProtectionKey] ofItemAtPath:dbdir error:nil];

// Database file
[fileManager setAttributes:[NSDictionary dictionaryWithObject:NSFileProtectionNone forKey:NSFileProtectionKey] ofItemAtPath:dbname error:nil];

@markarupert
Copy link

I am dealing with this issue right now. On iOS I am communicating to a BLE device in the background when the the phone is locked. I am not getting an error in my queries it just is not returning from the transaction.

I see this issue is 4 years old. Were there any changes that would resolve this? I see the recommendation for using NSFileProtectionNone. Is that something that was or could be implemented?

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

No branches or pull requests

4 participants