I am trying to implement apple watch extension. I need to call my iPhone application class methods to trigger the web request. I saw this method in apple documentation i am trying the same.But this method is not calling
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
any help on this is appreciated. https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html
Here is my code snippet:
#import "InterfaceController.h"
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
// Configure interface objects here.
NSString *requestString = [NSString stringWithFormat:@"callMyRequest"];
NSDictionary *applicationData = [[NSDictionary alloc] initWithObjects:@[requestString] forKeys:@[@"theRequestString"]];
[WKInterfaceController openParentApplication:applicationData reply:^(NSDictionary *replyInfo, NSError *error) {
NSLog(@"\nReply info: %@\nError: %@",replyInfo, error);
}];
}
#import "Appdelegate.h"
#import "MyController.h"
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^) (NSDictionary *replyInfo))reply {
NSString * request = [userInfo objectForKey:@"requestString"];
if ([request isEqualToString:@"callMyRequest"]) {
// Do whatever you want to do when sent the message. For instance...
MyController* myController = [[MyController alloc] init];
[myController callMyRequest];
}
reply nil;
}