6
votes

Good day

I have an IOS messaging app. The app stores messages received and sent in a sqlite3 database and the app also generates log files. This can happen in foreground or as background tasks

When passcode is disabled on the IOS device everything works fine.The log files are created and the database entries can be inserted successfully in any mode of operation, even while the screen is off and the app minimised.

When the Iphone's screen is locked with a passcode it seems that the app can not access any files. My log file pointers stay null and I get this error when I try to add to the database: "sqlite_exec() -> disk i/o error."

The data protection capability is disabled. I am using background fetch and voip capabilities to execute background tasks. The code handling the database and log files are written in C and compiled separately.

Thanks

1
Hi, did you find a solution for this problem?suprandr

1 Answers

4
votes

iOS encrypts the files when the phone is locked with a pass code. So if your really need to create new files while the application is running in background, you need to mark those parent folder in which you want to create folder as unprotected.

[[NSFileManager defaultManager] setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider tmpFolder] error:NULL];
[[NSFileManager defaultManager] setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider documentsFolder] error:NULL];