Bring iOS App to Foreground in WatchKit - ios

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?

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?

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.

Related

Is possible start a iOS App on device boot?

I am developing iOS App (iPhone/iPad) that needs be started when the device is turned on.
The app should be started on device boot.
Is this possible on iOS using Swift?
It's not possible to start your app whenever the device boots. Depending on what you need, there may be other alternatives such as running some code in the background when the app receives a Push Notification or turning on Background Fetch, though in the latter case, the system still has control on when to launch your app.

How to auto launch Apple Watch app when companion iOS app is running?

I believe it's RTFM kind of question, but I can't find the answer. I've created Apple Watch app which works just fine, gets paired with its companion iOS app, receives push notifications sent to main app, but it does not start when iOS app gets launched. Am I missing something? Should I run a background task just to check if main iOS app is alive?

Make iOS application run at startup iPhone or iPad

I would like to do my app open when iPhone is turned on. I saw that have some people saying can be using voip key in Info.plist but I tried and can't to do that. Do someone have any idea to help me? Thanks
In short, iphone does not have any access to permission to edit about "onboot" or "onstartup."
Thus, without jailbreaking this would not be possible.
Check the links I provided on your comment.
This would not happen, your app will be active in background through pushkit only when your app dismissed before device goes off.
VOIP - The app provides Voice-over-IP services. Apps with this key are automatically launched after system boot so that the app can reestablish VoIP services. Apps with this key are also allowed to play background audio.
Even with "voip" present in "UIBackgroundModes" in "plist", iOS App does not auto start after device reboot in iOS10
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1

Is it possible to use WatchConnectivity in background

I have an watchOS app that used WatchConnectivity framework to open an URL in Safari. When my app is running on the iPhone and running on the Apple Watch at the same time, pressing the open URL button on the Apple Watch app does launch Safari on the iPhone as what I've implemented using WCSessionDelegate. But this won't work if the iPhone app is not running. Is there a way to launch the URL on iPhone when pressing the button on the Apple Watch even if the iPhone app is not active? Thanks.
Using the WatchConnectivity's sendMessage API the watch app is able to get the phone to launch your iOS app in the background, but a background running iOS app won't be able to open the URL resulting in Safari being launched.
No, Apple does not allow you to start an iPhone app from the watch (although a lot of developers seem to want this functionality.) You can always enter an enhancement bug request.

Is it possible to know which app is running in foreground of a iOS device when our app is in background?

For example: let's say that the user is using the Facebook app, is it possible to know for another app in the same device (which is running in background) that the Facebook app is running in the foreground?
As Paul mentioned, you cannot find out which app is running in the foreground while you are in the background.

Resources