GCDWebUploader支持iOS进入后台后仍然可以进行传输

参考文章:https://www.jianshu.com/p/2bab0ef93f7d

 

1.开启支持后台模式:将GCDWebServer.m中的GCDWebServerOption_AutomaticallySuspendInBackground设置为NO;

2.APPDelegate中

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    __weak typeof(self) weakSelf = self;
    self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
        [application endBackgroundTask:weakSelf.backgroundTask];
        weakSelf.backgroundTask = UIBackgroundTaskInvalid;
        
    }];
}

 

posted @ 2019-04-03 17:12  YouNeedCourage  阅读(998)  评论(0编辑  收藏  举报