how do i make a call from a button

i would like to use a button in my app ato make a phone call, can any one help me with the right code

The best you can do is call a url string that will open the built-in phone app...is that what you want?

I would like some help with that KMT! can you see what i did wrong in my code the app crashes when i press the call button

Code Block
//
// ViewController.swift
// Diabell App
//
// Created by Richard Klug on 23/04/2021.
//
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
 override func viewDidLoad() {
  super.viewDidLoad()
  // Do any additional setup after loading the view.
 }
  
 //Function Email Bottom Left
  
 @IBAction func Mail(_ sender: Any) {
  showMailComposer()
 }
  
 func showMailComposer() {
   guard MFMailComposeViewController.canSendMail() else{
    return
   }
   let composer = MFMailComposeViewController()
   composer.mailComposeDelegate = self
   composer.setToRecipients(["richard.klug@diabell.se"])
   composer.setSubject("Diabell App Help")
   composer.setMessageBody("Fyll i vad du behöver hjälp med", isHTML: false)
   present(composer, animated: true)
 }
  
 //Funktion Call Bottom Right
  
 @IBAction func callButtonClicked(_ sender: Any) {
 }
  private func callNumber(phoneNumber:String) {
   if let phoneCallURL = URL(string: "tel://\(+46706106310)") {
   let application:UIApplication = UIApplication.shared
   if (application.canOpenURL(phoneCallURL)) {
    application.open(phoneCallURL, options: [:], completionHandler: nil)
   }
   }
  }
}


@Richard_Klug
Where exactly do you crash ?
What crash log do you get ?

There is something curious in your code: callButtonClicked is an empty func
Code Block
@IBAction func callButtonClicked(_ sender: Any) { }

In addition, callNumber() func is not called anywhere…

Notes:
  • if the sender is a button, it is better to use UIButton type as sender instead of Any.

  • it is not a good practice on the forum to use another thread (even more when it is 4 years old) to ask an additional question. Open a new thread and if needed paste a reference to the older thread.

how do i make a call from a button
 
 
Q