iOS application handleWatchKitExtensionRequest launches the app in background?

Hello,

I noticed something weird. In iOS, the method application:handleWatchKitExtensionRequest (for the Apple Watch) launches the game in background.

I know the Watchkit extension is supposed to communicate with the iPhone, but is it supposed to like “launch” the game? Because right now what happens is that as soon as this method is called, the game runs. I have my logs from my home scene and stuff happening, just without the app opened.

Then if I go in my app I have some errors (due tu network download that didn’t work during this time), and I don’t think Apple accept apps behaving like this.

Is this normal? Is there something special to do so that my calls to this method won’t launch the whole game?

Thanks

I just added this code in the AppCoronaDelegate:

- (void)application:(UIApplication \*)application handleWatchKitExtensionRequest:(NSDictionary \*)userInfo reply:(void(^)(NSDictionary \*replyInfo))reply { NSLog(@"%s", "[MQD] RECEIVED APPLE WATCH REQUEST"); NSError \*error; NSArray \*paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString \*documentsDirectory = [paths objectAtIndex:0]; NSString \*filePath = [documentsDirectory stringByAppendingPathComponent:@"player\_profile.json"]; NSFileManager \*fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:filePath] == NO){ printf("[MQD] FILE DOESN'T EXIST"); reply(@{@"tmtc":@"fail"}); } else { NSLog(@"%s", "[MQD] File exists"); NSLog(@"%@", filePath); NSString \*fileContent = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; // NSString \*fileContent = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding]; NSLog(@"%@", fileContent); printf("[MQD] ALLO"); reply(@{@"tmtc":fileContent}); } }

Also, something maybe more important: A lot of time, if the app is not running, the main application will just never reply to the Watch, with nothing particular in the logs. I’m pretty sure there is something happening with the Corona Delegate that is not the expected behavior for handling extension requests. 

What happens, I think, is that the app launches, goes all through the main and all the lua code, and only until all that is done, it starts answering to things like the watchkit request. But it’s killed by iOS before it comes to that point because the app is launched in background, while it should not be.

Also, something maybe more important: A lot of time, if the app is not running, the main application will just never reply to the Watch, with nothing particular in the logs. I’m pretty sure there is something happening with the Corona Delegate that is not the expected behavior for handling extension requests. 

What happens, I think, is that the app launches, goes all through the main and all the lua code, and only until all that is done, it starts answering to things like the watchkit request. But it’s killed by iOS before it comes to that point because the app is launched in background, while it should not be.