RichieBackgroundDownloadManager
Objective-C
@interface RichieBackgroundDownloadManager : NSObject
Swift
class RichieBackgroundDownloadManager : NSObject
This class provides support for easily handling NSURLSession background downloads introduced in iOS 7.
Initialize a single instance in @p -application:didFinishLaunchingWithOptions: and keep a strong reference to it. Pass the instance to Richie and Maggio when creating those to enable background downloads.
See documentation for reconnectToActiveDownloads
and @p -handleEventsForBackgroundURLSession:completionHandler:
for more information on how to integrate RichieBackgroundDownloadManager with UIApplication.
NOTE: Create only one instance of RichieBackgroundDownloadManager. Use the instance from the main thread only.
-
Returns YES if given idenfier indicates that it belongs to RichieBackgroundDownloadManager. This way your application can have other background URL sessions and distinguish between those and the ones that belong to RichieBackgroundDownloadManager.
Declaration
Objective-C
- (BOOL)shouldHandleEventsForBackgroundURLSessionWithIdentifier: (NSString *)identifier;
Swift
func shouldHandleEventsForBackgroundURLSession(withIdentifier identifier: String!) -> Bool
-
Call this method directly from UIApplicationDelegate callback @p -application:handleEventsForBackgroundURLSession:completionHandler:, but only if the receiver returns YES from @p -shouldHandleEventsForBackgroundURLSessionWithIdentifier:.
Declaration
Objective-C
- (void)handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler;
Swift
func handleEvents(forBackgroundURLSession identifier: String!) async
-
Call this when the app is launched, preferably in @p -application:didFinishLaunchingWithOptions:. This is needed for progress updates during downloads.
Declaration
Objective-C
- (void)reconnectToActiveDownloads;
Swift
func reconnectToActiveDownloads()