İşlemimiz çok basit aşağıdaki methodu projesine ekleyin daha sonra bir buton click yardımıyla aşağıdaki gibi çağırın. Bunu extension method'ta yapabilirsiniz.
func callNumber(phoneNumber:String) {
let callNumber = phoneNumber.replacingOccurrences(of: " ", with: "")
if let phoneCallURL = URL(string: "tel://\(callNumber)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
application.open(phoneCallURL, options: [:], completionHandler: nil)
}
}
}
@IBAction func btnAra_Click(_ sender: Any) {
callNumber(phoneNumber: "0 555 444 33 22");
}
Sonuç:
#swift #swiftdersleri #iosdersleri
İyi Kodlar!