Is it possible to use WatchConnectivity in background - ios

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.

Related

Does it possibale to Develop an Apple Watch App to and IOS app to Support iOS Watches and other OS Watches

I have an iOS Application and am developing an Apple Watch Application for it.
The user should log in first to the iOS app and then we send the "Authentication log-in" to the iOS Watch App and the user can do some calls from its watch.
I'm Working on it as an extension of the main Application. and the Question is...
What is going to happen if the user has an iPhone and smartwatch which is not Apple?
Is there a way to send data from the iOS Application to the smartwatch (Android, Galaxy, and Huawei)?
Can the Application on the (Android, Galaxy, and Huawei) works like the one on the Apple Watch? or does it need a different development?.

Issues running Apple Watch glance app in simulator

I'm trying to test my apple watch glance for my iOS app using the simulator, however I'm getting some very strange behaviour. When I launch the iOS app in the simulator it works without problem and the app is fully functional. However , when I then try to launch the glance app for apple watch afterwards it shows up, but the iOS app no longer works (if I try to launch it from the simulator it immediately crashes) and the data that's in the app sharing group doesn't show up on the watch (but if I relaunch the iOS app simulator from Xcode it shows up there).
I've checked both apps and they are configured for the same sharing groups and that is definitely the case.
I just don't understand why running the iOS app and the apple watch app in the simulator won't work / behave correctly together?
Credit to #WhiteTiger for this answer:
if you're using watchos 2 appgroup the system does not work on the device, you should use wcsession as the documentation indicates.
Or look at updating to use the WatchConnectivity approach instead

Open Safari iOS App from Watch App

Is it possible to open the safari in iPhone when I click on some link in Apple watch Application?
This is only possible if the iOS app happens to be running in the foreground. If you use the WatchConnectivity sendMessage API to wake the iOS app up in the background then you won't be able to open URLs and therefore not launch Safari.

Can you launch the Apple Watch WK app from iPhone-side code?

WatchKit apps are extensions of iPhone code, however there is Watch-specific logic you can create for behavior of the app extension.
You can open Android Wear apps by passing an Intent from the phone to open a Wear-side Android app, but is there a similar way for the Apple Watch?
When you press a button on the iPhone app, for example, can you open its counterpart app extension on the Watch?
You can't open your apple watch app from your iphone. You can only execute background tasks from your apple watch to your iphone using openParentApplication

Bring iOS App to Foreground in WatchKit

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.

Resources