Swift
Building the interface
To be able to place the call, you need to add two elements to the screen:
- A
UILabelto show the connection status - A
UIButtonto start and end calls
Open ViewController.swift and add these two programmatically by replacing the entire file content with the following:
import UIKit
import VonageClientSDKVoice
class ViewController: UIViewController {
var connectionStatusLabel = UILabel()
var callButton = UIButton(type: .roundedRect)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
connectionStatusLabel.text = "Disconnected"
connectionStatusLabel.textAlignment = .center
connectionStatusLabel.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(connectionStatusLabel)
callButton.setTitle("Call", for: .normal)
callButton.translatesAutoresizingMaskIntoConstraints = false
callButton.alpha = 0
callButton.addTarget(self, action: #selector(callButtonPressed(_:)), for: .touchUpInside)
view.addSubview(callButton)
NSLayoutConstraint.activate([
connectionStatusLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
connectionStatusLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor),
callButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
callButton.topAnchor.constraint(equalTo: connectionStatusLabel.bottomAnchor, constant: 24)
])
}
@IBAction func callButtonPressed(_ sender: Any) {
}
}
The callButton has been hidden, its alpha is set 0, and will be shown when a the client creates a session.
Also, a target has been added for when callButton is tapped and will be used to place and end calls.
Build and Run
Run the project again (Cmd + R) to launch it in the simulator.

Making an in-app voice call
You make a voice call from an iOS app to a phone using thr iOS Client SDK.
手順
1
Introduction to this task2
Prerequisites3
Create a webhook server4
Create a Vonage Application5
Link a Vonage number6
Create a User7
Generate a JWT8
Xcode Project and Workspace9
Project permissions10
Building the interface11
VGVoiceClient12
Place a call13
What's next?