Type Method

backgroundSessionConfigurationWithIdentifier:

Returns a session configuration object that allows HTTP and HTTPS uploads or downloads to be performed in the background.

Declaration

+ (NSURLSessionConfiguration *)backgroundSessionConfigurationWithIdentifier:(NSString *)identifier;

Parameters

identifier

The unique identifier for the configuration object. This parameter must not be nil or an empty string.

Return Value

A configuration object that causes upload and download tasks to be performed by the system in a separate process.

Discussion

Use this method to initialize a configuration object suitable for transferring data files while the app runs in the background. A session configured with this object hands control of the transfers over to the system, which handles the transfers in a separate process. In iOS, this configuration makes it possible for transfers to continue even when the app itself is suspended or terminated.

If an iOS app is terminated by the system and relaunched, the app can use the same identifier to create a new configuration object and session and retrieve the status of transfers that were in progress at the time of termination. This behavior applies only for normal termination of the app by the system. If the user terminates the app from the multitasking screen, the system cancels all of the session’s background transfers. In addition, the system does not automatically relaunch apps that were force quit by the user. The user must explicitly relaunch the app before transfers can begin again.

You can configure an background session to schedule transfers at the discretion of the system for optimal performance using the discretionary property. When transferring large amounts of data, you are encouraged to set the value of this property to YES.

For more information about uploading and downloading files in the background, see URL Session Programming Guide.

See Also

Creating a Session Configuration Object

defaultSessionConfiguration

Returns a newly created default session configuration object.

ephemeralSessionConfiguration

Returns a session configuration that uses no persistent storage for caches, cookies, or credentials.