swiftwatchkitapple-watchwatchos

Open Apple Watch app from another watch app


I am looking for a way to open an apple watch app from another apple watch app. I have found answers for iOS apps. I am looking for something similar to this answer, but for watchOS instead of iOS.

I have tried to duplicate the iOS answer for watchOS but had no luck. The code I used is:

func openApp() {
    let url = URL(string:"App Name")
    WKExtension.shared().openSystemURL(url!)
}

I was hoping this would open the app, however, nothing happened when the function was called.


Solution

  • 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.