IOS app cannot access files in background when screen is locked with password

good afternoon

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

When the password code is disabled on the iOS device, everything works fine. Log files are created, and database records can be successfully inserted in any mode of operation, even when the screen is off and the application is minimized.

When the iPhone screen is locked with an access code, it seems that the application cannot access any files. My log file pointers remain empty, and I get this error when I try to add to the database: "sqlite_exec () → I / O drive error."

The data protection function is disabled. I use background fetching and voip to do background tasks. The code that processes the database and log files is written in C and compiled separately.

thank

+4
source share
1 answer

iOS encrypts files when the phone is locked with an access code. Therefore, if you really need to create new files when the application is running in the background, you need to mark the parent folder in which you want to create the folder as insecure.

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

All Articles