As I watched the WWDC 2015 session video "Introducing WatchKit for watchOS 2" (at 13:29), I saw that it is possible to make phone calls directly on Apple Watch with the openSystem API. How can I use this API in Swift?
Asked
Active
Viewed 1,446 times
1
-
1Did you try to find the documentation for openSystem API? Such things are usually explained in API documentation. – Nick Volynkin Jun 17 '15 at 03:10
2 Answers
8
You can use the openSystemURL
method, which is available on the shared WKExtension
object. Pass a tel:
URL to this method to initiate a phone call.
if let telURL=NSURL(string:"tel:5553478") {
let wkExtension=WKExtension.sharedExtension()
wkExtension.openSystemURL(telURL)
}

Paulw11
- 108,386
- 14
- 159
- 186
-
-
Did you set a breakpoint to make sure the code is being called and that the url isn't nil? – Paulw11 Jun 14 '15 at 11:17
-
-
My code: `@IBAction func phoneCall() { if let telURL=NSURL(string:"tel:5553478") { let wkExtension=WKExtension.sharedExtension() wkExtension.openSystemURL(telURL) } } ` – dev Jun 14 '15 at 11:40
-
-
It's very strange...the sms is working now but the phone isn't I tried with many number's i know...maybe it's a bug in the SDK? – dev Jun 14 '15 at 12:23
-
1
-
it works, but prompts the user and user should accept the call process. – mkhoshpour Dec 15 '18 at 11:23
0
There seems to be a bug in beta 1 that is not allowing the use of openSystemURL on phone numbers. I've seen several sample projects as well as banged my own head against the wall attempting to get going. No implementation I've seen works. SMS works fine however.

SprayKid982
- 333
- 3
- 16