The Salesforce Engagement SDK requires access to files on the iOS device file system. Some iOS Data Protection modes can prevent the SDK from accessing the needed files at certain times. During normal operation, the SDK requires access to files while running in the foreground and while running in the background. If the SDK can’t access these files because it’s prohibited by the iOS Data Protection mode, the SDK logs an error.
By default, the SDK sets the file protection type to NSFileProtectionCompleteUntilFirstUserAuthentication. With this file protection type, files are stored in an encrypted format on disk and can’t be read from or written to until the user unlocks the device for the first time. In version 8.0.9 or later of the SDK, the SDK retains the default protection type (NSFileProtectionCompleteUntilFirstUserAuthentication). It also provides the capability to override the file protection type within the consuming application. Specify a different file protection type, such as NSFileProtectionComplete and NSFileProtectionCompleteUnlessOpen, if your application requires it.
SDK Behavior by Protection Level
iOS Data Protection affects the SDK as described in this table.
iOS Data Protection Level
SDK Behavior
No protection
SDK works in the foreground and background
Complete until first user authentication
SDK works in the foreground and background after the first unlock
Complete unless open
SDK works in the foreground and background after the first unlock
Complete
SDK works only in the foreground after the device is unlocked
Override the File Protection Type
The following example shows how you can override the file protection type.
For an additional example of overriding the file protection type, see the learning application.
Handle Configuration Issues
If you configure iOS data protection such that the file system isn’t accessible during the SDK configuration call, the SDK retries the call for up to 5 seconds. This retry period allows time for a user to unlock the device and make the file system accessible. If the user doesn’t unlock the device within 5 seconds, an error object is returned describing the error, and the configuration call fails, returning false. In this case, the SDK isn’t configured. Don’t attempt to access SDK methods until the configure method returns true. The error object returns the error code configureDatabaseAccessError.
Handle Foreground and Background Operation Issues
Some features of the SDK require access to the file system when the app transitions to the foreground or to the background. Foreground operations include retrieving messages for inbox messaging, location messaging, and sending analytic information back to Marketing Cloud Engagement. Background operations include sending analytic information to Marketing Cloud Engagement. If you enable any of these features via configuration, select an appropriate iOS Data Protection mode.
If the FileProtectionType is NSFileProtectionComplete and the application goes to the background, NSSQLiteErrorDomain errors can appear in logs.