0

According to documentation,

WKInterfaceController.openParentApplication method launches the App in the background. But my host app will never launch when doing so. Is there anyone with experience with Watch App and WatchKit Extension, appreciate your help.

reference: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/clm/WKInterfaceController/openParentApplication:reply:

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jacky Wang
  • 618
  • 7
  • 27
  • Check this post: http://stackoverflow.com/questions/27048900/easy-way-to-update-app-content-via-apple-watch/27462225#27462225. Note: this is probably Xcode bug: if you set breakpoint in AppDelegate `handleWatchKitExtensionRequest` method it probably won't stop there, but you can run some code there to be sure this method works. – lvp Feb 04 '15 at 08:12

1 Answers1

2

As commenter described, you can use the handleWatchKitExtensionRequest in iphone app, and send a reply to the watchkit code. In the Simulator the Iphone app will not appear to open, as it is running in the background entirely, but it will return the reply if you setup this method.

If you manually open the app after starting the simulator, you can get the app to update via this method call, and see visual results.

Note, the Debug breakpoints will not stop on the Iphone app without setting that up. In Xcode, you can go to Debug menu, then follow "Attach to Process". I've selected both the Simulator Application as well as the IphoneApp's process to ensure it is linked. I have to do this each time I run the Simulator, but it gets breakpoints to hit in background for the iphone code. This is quite useful, but if there is an easier way, I'm eager to know.

Miro
  • 5,307
  • 2
  • 39
  • 64
  • Good to know that in Simulator it won't further open the app. I faced this problem, and thought it doesn't work. Instead as you said, I have to manually open the iPhone application on Simulator to make it works with Watch app. – haxpor Mar 10 '15 at 10:10
  • Why not just start debugging and when click "Home" button in simulator? The debugging will continue and you will have the app in background. – Alexander Volkov Jul 14 '15 at 09:21