title: iOS 10 Notification Content Extension: using NSURLSession?
body: <p>I'm trying to create a new Notification Content Extension in iOS 10 for local notifications where the notification view controller responsible for the content extension downloads an image from the network and renders it in a UIImageView. I have the Notification Content Extension target set up with an appropriate Info.plist and the content extension works beautifully for simple things like rendering a label with some content, for example the sample code that comes in the template:</p>
  
  <pre><code>func didReceive(_ notification: UNNotification) {
      self.label.text = notification.request.content.body
  }
  </code></pre>
  
  <p>However, when I try to introduce NSURLSession (or URLSession in Swift 3) into the mix, the notification content totally fails to load - not even the label gets set anymore:</p>
  
  <pre><code>func didReceive(_ notification: UNNotification) {
  
      self.label.text = notification.request.content.body
      let session = URLSession.shared()
      let url = URL(string: "https://chart.googleapis.com/chart?cht=p3&amp;chs=250x100&amp;chd=t:60,40&amp;chl=Hello|World")!
  
      let task = session.downloadTask(with: url) { (fileURL, response, error) in
          if let path = fileURL?.path {
              DispatchQueue.main.async {
                  self.imageView.image = UIImage(contentsOfFile:path)
              }
          }
      }
      task.resume()
  }
  </code></pre>
  
  <p>Is the usage of NSURLSession in the notification content extension not allowed? Is my extension possibly being killed before the download completes? If so, how could I ensure that it's not killed so I can download and render the image?</p>