title: Update data model on Apple Watch when phone app is in background
body: <p>I have written an iOS app that refreshes its data model when a push notification is received whilst the app is in the foreground, once the data is retrieved from the server I send that information to the watch kit app using:</p>
  
  <pre><code>// This code resides in ErrorsViewController.swift
  
  func updateWatchContext() {
      do {
          let messages = convertParseObjectsToJSON(tasks)
          try session?.updateApplicationContext(["messages" : messages])
      } catch let error as NSError {
          NSLog("Updating the context failed: " + error.localizedDescription)
      }
  }
  
  func convertParseObjectsToJSON(data:[PFObject])-&gt;[[String : AnyObject]]
  {
      var data = [[String:AnyObject]]()
      for var i = 0; i &lt; tasks.count; i++
      {
          let object = tasks[i]
          data.append([
              "createDate"   : object["createDate"],
              "errorMessage" : object["errorCode"]
          ])
      }
      return data
  }
  </code></pre>
  
  <p>This works fine when the application is in the foreground, the data model gets updated on the watch as expected.  However in the scenario that the phone is running in the background, how can I make a background fetch, parse the data and send it to the watchkit app without waking the iPhone, using watch connectivity?</p>
  
  <p>I was thinking about trying to add the code in AppDelegate, but I don't believe that will work.  I'd like to note that I do not want to make any network requests directly from the watch itself due to the limited CPU power; it would be un-necessary to handle the data parsing there.</p>