美文网首页swift4.0
iOS app进入后台后 应用保活 后台保活

iOS app进入后台后 应用保活 后台保活

作者: 279cb620c509 | 来源:发表于2019-01-04 10:48 被阅读0次

    iOS app进入后台后 应用保活 后台保活

      var bgTaskID: UIBackgroundTaskIdentifier = 0
    
      func applicationWillResignActive(_ application: UIApplication) {
    
    
    
            bgTaskID = UIApplication.shared.beginBackgroundTask() {
    
                // Completion handler to be performed if time runs out
    
               print("bgTaskID = UIApplication.shared.beginBackgroundTask()")
    
            }
    
    
       }
    
    
    
    func applicationDidBecomeActive(_ application: UIApplication) {
    
            // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    
            UIApplication.shared.endBackgroundTask(bgTaskID)
    
       }
    

    相关文章

      网友评论

        本文标题:iOS app进入后台后 应用保活 后台保活

        本文链接:https://www.haomeiwen.com/subject/pwlhrqtx.html