Skip to content

Instantly share code, notes, and snippets.

@choefele
Created May 16, 2015 21:03
Show Gist options
  • Save choefele/99654168c75d9bd81d9d to your computer and use it in GitHub Desktop.
Save choefele/99654168c75d9bd81d9d to your computer and use it in GitHub Desktop.
handleWatchKitExtensionRequest background task
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
let completionBlock: () -> Void = {
reply(nil)
UIApplication.sharedApplication().endBackgroundTask(self.updateCacheTask)
}
updateCacheTask = application.beginBackgroundTaskWithExpirationHandler(completionBlock)
if let userLocation = DataProviderUtils.userLocationForUserInfo(userInfo) {
DataProviderService.retrieveTripsForUserLocation(userLocation, completionBlock: completionBlock)
} else {
completionBlock()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment