I have currently a problem. My wanted behaviour: If I open my WatchKit App, I call "openParentApplication". I receive my wanted data. But if I tested on real devices, it doesnt work since I open the parent app in the iPhone. But when I'm testing in simulator it works without to open the parent app.
My Xcode Version is 6.3.2 and iOS 8.3.
What could be the problem?
InterfaceController.m
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
NSDictionary *userInfo = @{@"request":@"refreshData"};
[WKInterfaceController openParentApplication:userInfo reply:^(NSDictionary *replyInfo, NSError *error)
{
entries = replyInfo;
NSLog(@"Reply: %@",replyInfo);
[self reloadTable];
[self.city setText:[entries valueForKey:@"city"][0] ];
}];
}
AppDelegate.m
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
{
NSString *refresh = [userInfo valueForKey:@"request"];
if([refresh isEqualToString:@"refreshData"])
{
NSString *city = [[NSUserDefaults standardUserDefaults] stringForKey:@"City"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:[NSString stringWithFormat:@"http://blackdriver.adappter.de/api/retrieve.php?city=%@",[city stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
reply(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"Error: %@", error);
}];
}
}
EDIT - Correct answer: See the link from mohammed alwaili in the comments