on Android, i can store files into a fairly-protected file by using Context.openfileoutput
. it'll save to internal disk that is specific to my app, which isn't accessible to other apps, and the only way to get this is via connecting debugger/rooting device. this isn't 100% hack-proof, but it's good enough.
Is this something that exists on iOS?
i read https://developer.apple.com/library/content/qa/qa1699/_index.html, but is this safe? like i'm guessing it looks something like
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *librariesDirectory = [paths objectAtIndex:0];
NSLog(@"%@", librariesDirectory);
NSString *filePath = [NSString stringWithFormat:@"%@/%@/%@", librariesDirectory,@"Private", @"internal_image.jpg"];
Would this file be something that
- other apps can not access
- does not backup to icloud
- is easily visible to the app but NOT the end user
?
If you have sensitive information to store then the only really secure place to store it is in the key chain. Obviously you don't want to stick all of your data in the key chain, so instead just store an encryption key there and encrypt your information and store it in the documents directory. If someone accesses the documents directory, such as from an iCloud backup, they will not be able to read contents of the file without decrypting it.