Tae Hun Yu
Tae Hun Yu

Reputation: 39

How to add message Phone call alert popup?l

I wanna add message to phone call alert popup. how to make it?

enter image description here

Upvotes: 0

Views: 1169

Answers (1)

EgzonArifi
EgzonArifi

Reputation: 830

Yes, you can do it like that:

func phoneCall(to phoneNumber:String) {

    if let callURL:URL = URL(string: "tel:\(phoneNumber)") {

        let application:UIApplication = UIApplication.shared

        if (application.canOpenURL(callURL)) {
            let alert = UIAlertController(title: "Your Title", message: "Do you want call that number?", preferredStyle: .alert)
            let callAction = UIAlertAction(title: "Call", style: .default, handler: { (action) in
                application.openURL(callURL)
            })
            let noAction = UIAlertAction(title: "No", style: .cancel, handler: { (action) in
                print("Canceled Call")
            })
            alert.addAction(callAction)
            alert.addAction(noAction)
            self.present(alert, animated: true, completion: nil)
        }
    }
}

Upvotes: 2

Related Questions