How to programmatically open Apple Watch companion app from iOS app
I guess it's not possible to programmatically launch the watch companion app from iOS. The opposite way would be possible: to launch the iOS app in the background upon receiving a message from the watch. See WWDC talk Introducing Watch Connectivity.
You could check WCSession.defaultSession().watchAppInstalled
and ask the user to launch the app if it is true.
How to open a watch app from parent iOS app?
As @abjurato said, you can only launch it in a "workout mode"
import HealthKit
import WatchConnectivity
let healthStore = HKHealthStore()
func startWatchApp() {
print("method called to open app ")
getActiveWCSession { (wcSession) in
print(wcSession.isComplicationEnabled, wcSession.isPaired)
if wcSession.activationState == .activated && wcSession.isWatchAppInstalled {
print("starting watch app")
self.healthStore.startWatchApp(with: self.configuration, completion: { (success, error) in
// Handle errors
})
}
else{
print("watch not active or not installed")
}
}
}
func getActiveWCSession(completion: @escaping (WCSession)->Void) {
guard WCSession.isSupported() else { return }
let wcSession = WCSession.default()
wcSession.delegate = self
if wcSession.activationState == .activated {
completion(wcSession)
} else {
wcSession.activate()
wcSessionActivationCompletion = completion
}
}
Open Apple Watch app from another watch app
The documentation of the openSystemURL(_:)
method clearly states that the URL supplied to it has to support the tel:
or sms:
scheme and can only be used for starting a phone call or writing messages. It cannot be used to open any other applications, especially not 3rd party ones.
watchOS
doesn't support URL schemes at the moment (as of watchOS 5
), unlike iOS
, so you won't be able to open other apps from your app's WatchKit Extension.
Make phone call from Apple watch app
openURL
is silently ignored if the device is locked or the app is in the background. Additionally WatchKit doesn't contain an API for initiating a phone call.
Your best bet may be to prompt the user to open the iPhone app, possibly using Handoff, and tap a button to initiate the call from there. Not a great solution, but WatchKit is pretty limited right now.
Related Topics
Change the Text of a Label with a Button in iOS
Swift Unrecognized Selector Sent to Instance - What Am I Missing
Simulator Vs Physical Device: Navigationlink Broken After One Use
How to Set Style of the Statusbar Embedded in a Navigation Controller on iOS13
Insert a Floating Action Button on Uitableview in Swift
Replacement for Arkit in iOS10
Getting Email Address from Linkedin API
Call Extensiondelegate to Create/Refresh Data for Complication
How to Pair And/Or Bond to Ble on iOS Using Swift Code and an Hm-10 So Data Sent Is Encrypted
Bluetooth Didconnect or Didfailtoconnect Not Called Xcode 9.2 with iOS 11.1.2
Url Opening Swift App - Open Works - Called Function Does Not Work
Swift 3 Weird Crashes (Type Inference)
Swiftui: Error in Dragging Logic or Is This a Bug
How to Present Uiview (Xib) as Alert View in Swift
Xcode UI Tests Can't Find Views That Are Added Programmatically
Dynamic Height for a Uitableview Based on a Dynamic Collection View