简体   繁体   中英

Dial number with Name from iOS app

I have found the answer on how to dial a number programmatically from an app.

@IBOutlet weak var phoneNumberTextField: UITextField!

...

@IBAction func phoneDialButton(sender: UIButton) {

    let phoneNumberToCall = phoneNumberTextField.text

    let url: NSURL = NSURL(string: "tel://\(phoneNumberToCall)")!
    UIApplication.sharedApplication().openURL(url)

}

What I am curious about is if I introduce a new field

@IBOutlet weak var phoneNameTextField: UITextField!

How would I go about putting that string as the name you are dialing when you make the call? Is it even possible?

What you're asking for is not possible. The name that comes up when you dial a number is either the contact name associated with that number, or a suggested contact from your email. You would have to create a contact programmatically and associated the desired name with the number you want to dial, or update an existing contact if one for that phone number already exists.

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