Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make phone call with SwiftUI [duplicate]

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?

like image 721
Jonas Deichelmann Avatar asked Feb 25 '20 15:02

Jonas Deichelmann


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)
}
like image 192
Jawad Ali Avatar answered Oct 03 '22 01:10

Jawad Ali