简体   繁体   中英

How to open web link in Apple Watch application only?

My code is

    let url = NSURL(string: "https://www.google.com")
    WKExtension.shared().openSystemURL(url! as URL)

but I am getting popup message "URL failed to load This URL can be viewed on your iPhone"

Please suggest any way to open url in watch application.

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.

you can check the apple documentation from below link Apple documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM