I saw this SO post where apparently data was being fetched and returned to the Watch extension like so:
- (void)application:(UIApplication *)application handleWat
I think you got your code mixed up. You need to move the beginBackgroundTaskWithName to be inside your handleWatchKitExtensionRequest Make it the first thing you do, then call your function.
Simplified example:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *replyInfo))reply{
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask __block = [app beginBackgroundTaskWithName:@"watchAppRequest" expirationHandler:^{
NSLog(@"Background handler called. Background tasks expirationHandler called.");
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
//do your background task(s) here
if([requestString isEqualToString:@“myRequest"]){
//send reply back to watch
reply();
}
//end background task
[app endBackgroundTask:bgTask];
bgTask=UIBackgroundTaskInvalid;
}