How to make phone call with SwiftUI

Viewed 3410

How to make a Phone Call in SwiftUI. Here is the sample code with Swift and UIKit:

guard let number = URL(string: "tel://" + "+1(222)333-44-55") else { return }
UIApplication.shared.open(number)

Here is the thread for Swift and the UIKit Version:

How to make phone call in iOS 10 using Swift?

1 Answers
let numberString = "111-222-3334"

Button(action: {
    let telephone = "tel://"
    let formattedString = telephone + numberString
    guard let url = URL(string: formattedString) else { return }
    UIApplication.shared.open(url)
   }) {
   Text(numberString)
}
Related