alessandrom
9/17/2019 - 8:27 AM

Phone call tap gesture

// Tap gesture per avviare una telefonata
@objc func startCall(_ sender: UITapGestureRecognizer) {
    guard let phoneNumber = shopPhoneNumberLabel.text else {
        return
    }
    
    if( phoneNumber != "" ) {
        let noBlankPhoneNumber = phoneNumber.replacingOccurrences(of: " ", with: "")
        if let phoneUrl = URL(string: "telprompt:\(noBlankPhoneNumber)") {
            if( UIApplication.shared.canOpenURL(phoneUrl) ) {
                UIApplication.shared.open(phoneUrl, options: [:], completionHandler: nil)
            }
        }
    }
}