Reputation: 484
Is it possible to have a WatchKit app be a controller for it's parent iOS app?
I want to have buttons on the WatchKit app that cause an action on the iPhone app, but I can't find a way to get that going. Tried sending a notification - no joy.
Tried using WKInterfaceController.openParentApplication
but that doesn't work either.
Can someone point me in the right direction?
Thanks.
Ken
Upvotes: 1
Views: 223
Reputation: 5121
Here is what my handleWatchKitExtensionRequest looks like. Check the spelling of this method in your code. You didn't spell it right in the comment and that would cause a unrecognized selector crash.
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
NSString* command = [userInfo objectForKey:@"command"];
NSString* uuid = [userInfo objectForKey:@"uuid"];
if (command == nil)
{
reply(nil);
}
else
{
if ([command isEqualToString:@"startTrip"])
{
...
//The uuid of the trip is returned to the watch app
reply(@{@"uuid": uuid});
}
else if ([command isEqualToString:@"stopTrip"])
{
...
reply(nil);
}
else if ([command isEqualToString:@"pauseTrip"])
{
...
reply(nil);
}
else if ([command isEqualToString:@"resumeTrip"])
{
...
reply(nil);
}
}
}
Upvotes: 0
Reputation: 1129
See example from the blog of @NatashaTheRobot:
http://natashatherobot.com/watchkit-open-ios-app-from-watch/
Upvotes: 1