I developed and deployed the Apple Watch Extension application using a simulator. It has been approved and is available right now in the app store, so Apple is happy!
Today I was able to get a physical watch and discovered a real problem - I can only interact with a watch phone if the application on my phone is not only open, but also active ... thus defeating the object.
I use the method below in appDelegatethe phone application as a proxy server to get real-time data and return it to the clock.
I basically pass the request to appDelegate- I check userInfo for what data needs to be returned, then the phone application does the business and returns the userInfo dictionary containing the data to view the data:
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
if ([userInfo objectForKey:@"GetWatchData"]) {
[TPWatchData configureWatchData:^(BOOL success) {
if (success) {
reply([TPWatchData watchData]);
} else {
reply(@{@"FAIL":@"AppDelegate"});
}
}];
}
}
I call it in hours using this approach on watch extension(just one example of the calls I make):
[TPWPlanList openParentApplication:@{@"GetWatchData":@1} reply:^(NSDictionary *replyInfo, NSError *error) {
if ([replyInfo objectForKey:@"Overview"]) {
if (error.code == 0) {
if ([replyInfo objectForKey:@"FAIL"]) {
} else {
self.dic_overview = [replyInfo objectForKey:@"Overview"];
}
} else {
}
}
}];
As already mentioned, this worked fine in the simulator and actually works great on the physical clock - but ONLY if I have the main application open on the phone and active. While the application is in the background or the phone’s display is sleeping, data is not transmitted using the above method.
Any thoughts? I obviously am doing something wrong, but I managed to thoroughly bring to the end my whole life on real devices, before she bit me.
Many thanks!