Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's not enough information to suggest a concrete solution to your problem.</p> <p>Here are some principal requirements:</p> <ul> <li><p>Since you want a background task, ensure you created a suitable <code>NSSession</code> object through <code>backgroundSessionConfiguration:</code>. Using this class factory method is mandatory for getting <em>background sessions</em>.</p></li> <li><p>For requests running in the background in a separate process, only <em>upload</em> and <em>download</em> tasks are supported. Note that, in your original code, you are using a <em>data</em> task.</p></li> <li><p>Ensure you have <em>properly</em> implemented the delegate method <code>application:handleEventsForBackgroundURLSession:completionHandler:</code> in your App Delegate. When your app is not running, and when the session is running in its own process and requires credentials, iOS will restart your app in the background and the background session will call this delegate method. See also <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:handleEventsForBackgroundURLSession:completionHandler" rel="nofollow noreferrer">https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:handleEventsForBackgroundURLSession:completionHandler</a>:</p></li> </ul> <p>Disabling server trust evaluation should work as you tried in your first example. <strong>Use this for development only!</strong></p> <p>See also (<a href="https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html#//apple_ref/doc/uid/TP40013509-SW44" rel="nofollow noreferrer">https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html#//apple_ref/doc/uid/TP40013509-SW44</a>)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload