When does NSURLSession run?

后端 未结 3 655
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 14:20

I have a situation in which when the device receives a push notification, I would send a NSURLSession combined with a NSURLConnection. I have a couple

3条回答
  •  野的像风
    2021-02-09 14:55

    If you use background configurations with NSURLSession the delegates are getting called on success/failure when your app is Active or in the background. The task you created are handed over to a demon of the OS and your app is being waken up or even started (if it killed by iOS) using

    `application:handleEventsForBackgroundURLSession:completionHandler`:
    

    And when all the tasks completed your session delegate would be called with

    URLSessionDidFinishEventsForBackgroundURLSession:   
    

    More details on background session are here

    You can also get apple sample code here and look for "Simple Background Transfer"

提交回复
热议问题