Is there any way to launch the iOS App from Apple Watch?
Edit:- Tried using both api below but doesn't work:-
Apple Watch Code
Calling Inside interfaceController.m
+ (BOOL)openParentApplication:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo, NSError *error)) reply; // launches containing iOS application on the phone. userInfo must be non-nil
iOS Code
Calling Inside Appdelegate.m
- (void) application:(UIApplication *) application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
The answer is actually pretty interesting. It is YES
and NO
.
You CAN open the app in the background through the openParentApplication:reply:
method. That will launch the app in the background if it is terminated or backgrounded. It will just call the app if it is already in the foreground.
You CANNOT bring the iOS App to the foreground from the Watch Extension if it is not already foregrounded. That is against Apple's policies. While you can actually do it in the iOS Simulator, Apple has confirmed that you cannot do this on the device or submit the solution to the App Store. See this article on the dev forums for more information.
If you need to bring the iOS App to the foreground, the only way you can partially do this at the moment is to use the Handoff APIs. Here is another link to the Handoff Programming Guide. Once you read both of those documents carefully, you'll see exactly how the Handoff system works.
To implement, you'll need to add the WKInterfaceController
updateUserActivity:userInfo:webpageURL:
in the Watch Extension. Then you'll need to implement the UIApplicationDelegate
application:continueUserActivity:restorationHandler:
in your iOS app. Unfortunately, you will not be able to test this solution until you have an Apple Watch, but the docs clearly state this will be supported.