I am developing a WatchKit extension for one of my Apps where I really want to have the iPhone App running in the foreground, since it is doing the heavy lifting and is designed to use location services only when active. I know openParentApplication:reply only opens the App in the background (unless it is already active). What I am currently trying out is using a custom URL scheme for my App, and having the App initially open itself from within the handleWatchKitExtension code in the App Delegate. This works perfectly in the Simulator. Unfortunately I did not have this approach ready when I tested my App on real Apple Watches. Does anyone see a problem with this approach to bring the iPhone App to the foreground from the Apple Watch?
Asked
Active
Viewed 1,124 times
5
-
1See my detailed answer [here](http://stackoverflow.com/a/28823756/1342462). You cannot do this according to Apple. – cnoon Mar 24 '15 at 15:48
-
possible duplicate of [How to launch iOS App from Apple Watch?](http://stackoverflow.com/questions/28760986/how-to-launch-ios-app-from-apple-watch) – Sagi Iltus Apr 23 '15 at 22:27
-
I can confirm, this does not work on a real watch. If you try, your app will get rejected. In short, the reason is that `openURL` cannot be called from a background state and since openParent, opens your app in background mode, it cannot call `openURL`. Yes, it does work in the simulator but not in real hardware. – rmp Apr 23 '15 at 23:15
2 Answers
1
On iOS, apps can't bring themselves to the foreground. The best thing you can do is to post a local notification (UILocalNotification
, see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html) and invite the user to bring your app to the foreground.
But for your use case, why not just have your phone app use location services in the background?

jrc
- 20,354
- 10
- 69
- 64
0
This is not possible. The Apple Watch Programming Guide states that the app on the iPhone will run in the background if it was not active before.

John
- 8,468
- 5
- 36
- 61