问题版本:xcode12.2 , iOS14.2,  iOS的定时器,RxSwift5.1.1 的定时器都有效

AppDelegate的applicationDidEnterBackground添加

 

swift 

    func applicationDidEnterBackground(_ application: UIApplication) {
        UIApplication.shared.beginBackgroundTask {
            UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid)
        }
    }

  

OC

- (void)applicationDidEnterBackground:(UIApplication *)application{
    [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        [[UIApplication sharedApplication]endBackgroundTask:UIBackgroundTaskInvalid];
    }];
}

  

 

参考:

https://blog.csdn.net/u013983033/article/details/85694452?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control

posted on 2020-11-19 14:16  懂事长qingzZ  阅读(610)  评论(0编辑  收藏  举报