Last active
August 29, 2015 14:26
-
-
Save Ingelheim/56a236934ac055bf45b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(application: UIApplication, | |
handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) { | |
// This needs to be done to keep the app busy, before the process is killed bu the phone | |
var workaround: UIBackgroundTaskIdentifier? | |
workaround = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({ | |
UIApplication.sharedApplication().endBackgroundTask(workaround!) | |
}) | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), { | |
UIApplication.sharedApplication().endBackgroundTask(workaround!) | |
}) | |
var realBackgroundTaks: UIBackgroundTaskIdentifier? | |
realBackgroundTaks = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({ | |
UIApplication.sharedApplication().endBackgroundTask(realBackgroundTaks!) | |
}) | |
// Do here what you want to do, e.g. handle the request from the watch | |
// reply([:]) | |
UIApplication.sharedApplication().endBackgroundTask(realBackgroundTaks!) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment