How to use openURL for making a phone call in Swift?

I am pretty sure you want:

UIApplication.sharedApplication().openURL(NSURL(string: "tel://9809088798")!)

(note that in your question text, you put tel//:, not tel://).

NSURL’s string init expects a well-formed URL. It will not turn a bunch of numbers into a telephone number. You sometimes see phone-number detection in UIWebView, but that’s being done at a higher level than NSURL.

EDIT: Added ! per comment below

Leave a Comment