Note: iOS Data Protection affects the SDK as follows:

  1. No protection - SDK works in foreground & background
  2. Complete until first user authentication - SDK works in foreground & background after 1st unlock.
  3. Complete unless open - SDK works in foreground & background after 1st unlock.
  4. Complete - SDK works only in the forground after the device is unlocked.

The MarketingCloud SDK requires access to files on the iOS Device file system. Some iOS Data Protection modes may prevent the SDK from accessing the needed files at certain times. During normal operation, the SDK must have access to files while running in the foreground and while running in the background. If the SDK cannot access these files due to an iOS Data Protection mode, an error is logged and the file access will fail.

The MarketingCloud SDK sets the file protection type by default to NSFileProtectionCompleteUntilFirstUserAuthentication. This means the files are stored in an encrypted format on disk and cannot be read from or written to until the user unlocks the device for the first time. The MarketingCloud SDK, as of version 8.0.9, will continue to retain the default protection type (i.e. NSFileProtectionCompleteUntilFirstUserAuthentication), but also provides a capability to override (e.g. to NSFileProtectionComplete, NSFileProtectionCompleteUnlessOpen, etc) the file protection type within the consuming application.

NOTE: NSSQLiteErrorDomain errors will appear in logs if the FileProtectionType is NSFileProtectionComplete and the application goes in the background

How To Override FileProtectionType

See the learning application for an additional example.

Configuration Issues

In the case of configuration, if iOS Data Protection is set such that the file system is not accessible when the call to configure the SDK is made, the configuration call will be retried for up to 5 seconds allowing time for a user to unlock the device and make the file system accessible. If the user does not unlock the device within the 5 seconds an error object is returned describing the error and the configuration call will fail returning false. When this happens the SDK is NOT configured and no access to any SDK methods should be attempted until the configure method returns true. The error code returned in the error object will be ‘configureDatabaseAccessError’.

Foreground/Background Operation Issues

Certain features of the SDK require access to the file system while transitioning to the foreground or background. Foreground operations include retrieving messages from the Marketing Cloud for Inbox and Location and sending analytic information back to the Marketing Cloud. Background operations include sending analytic information back to the Marketing Cloud. If any of these features are enabled via configuration then an appropriate iOS Data Protection mode must be selected in order for them to work correctly.