how to handle completionHandler in phone call method in ios swift

I have a two methods like phone call and video capturing. My question is that How can I call the video capturing method after phone call completed.I think it is possible with the completionHandlers. But I don't know how to handle this.can any one guide to me to do this task?

func makeCall(phoneNumber: String) {
    let formattedNumber = phoneNumber.components(separatedBy:NSCharacterSet.decimalDigits.inverted).joined(separator: "")

    let phoneUrl = "tel://\(formattedNumber)"
    let url:NSURL = NSURL(string: phoneUrl)!

    if #available(iOS 10, *) {
        UIApplication.shared.open(url as URL, options: [:], completionHandler:
            nil)


    } else {
        UIApplication.shared.openURL(url as URL)
    }
}

func videocapture(){

      print("video")
}

1 answer

  • answered 2018-11-08 06:53 Natarajan

    The completionHandler in open(url.. method is only to determine whether the phone call is started successfully or not. But you can't determine whether the phone call is ended or not. Because once the phone call ended, the user will be stays only on phone app as mentioned(Please read the comments) in below thread.

    How to detect a call made using openUrl() is ended in ios