Make your first call
Sendbird Calls for iOS enables real-time voice and video calls for 1-to-1 calls or group calls among users within your Sendbird-integrated app. Our development kit can initialize, configure, and build voice and video calling functionality in your iOS app.
Sendbird Calls supports both Direct call and Group call. Follow the guide below to make your 1-to-1 call or start a group call from scratch using Swift and Objective-C.
Note: For a more detailed guide on building voice and video calling functionality in your app, see our iOS video chat tutorial.
Requirements
The minimum requirements for Calls SDK for iOS are the following.
- iOS 12.0 and later
- Swift 5.0 and later
- Xcode 15.0 and later
Note: Starting on April 29, 2024, you must build and test your app with Xcode 15.0 or later to submit to the App Store. You can use the existing Sendbird SDK versions built with both Xcode 13.x and Xcode 14.1+ but Sendbird is repackaging Calls for iOS with Xcode 15.0 and minimum iOS version of 12.0 starting on April 29, 2024.
Get started
You can start making a 1-to-1 call with Direct call or create a room to start a group call with Group call by installing Sendbird Calls for iOS.
Step 1 Create a project
Open Xcode and create a new project. Sendbird Calls supports Swift and Objective-C.
Step 2 Install the SDK
You can install Calls for iOS using Swift Package Manager, CocoaPods, or Carthage.
Swift Package Manager
- Go to your Swift Package Manager's File tab and select Swift Packages.
- Then choose Add package dependency.
- Add the
SendBirdCalls
framework into your Package Repository with the following URL:https://github.com/sendbird/sendbird-calls-ios
. - To add the package, select the appropriate dependency rule and click Add Package.
CocoaPods
- Create a file called
Podfile
in your project directory as shown below.
- Add the
SendBirdCalls
framework into yourPodfile
in Xcode as below.
- Install the
SendBirdCalls
framework through CocoaPods by running the following command.
Carthage
- Create a file called
Cartfile
in your project directory as shown below.
- Add
SendbirdCalls
andWebRTC
into yourCartfile
as below.
- Update the
SendBirdCalls
framework through Carthage by running the following command.
- Go to your Xcode project target’s General tab in the Frameworks, Libraries, and Embedded Content section. Then drag the built
.xcframework
binaries from the<YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build/iOS
folder into your application's Xcode project.
Step 3 Request permission to access camera and microphone
Your users need to grant your app the permission to access camera and microphone on the device.
-
Add the
NSMicrophoneUsageDescription
key in your app’sInfo.plist
file to access microphone for audio call. -
Add
NSCameraUsageDescription
in your app’sInfo.plist
file to access camera for video call.
Step 4 Initialize the Calls SDK
To integrate and run Sendbird Calls in your application, you need to initialize it first. Initialize the SendBirdCall
instance by using the Application ID of your Sendbird application, which can be found on Sendbird Dashboard after creating an application. If the instance is initialized with a different Application ID, all existing call-related data in a client app will be cleared and the SendBirdCall
instance will be initialized again with the new Application ID.
Note: Each Sendbird application can be integrated with a single client app. Within the same application, users can communicate with each other across all platforms, whether they are on mobile devices or on the web.
Step 5 Authenticate a user
To make and receive a 1-to-1 call or start a group call, authenticate a user to the Sendbird server by using their user ID through the authenticate()
method.
After authenticating a user, you can continue to either make a 1-to-1 call with Direct call or start a group call with Group call. Skip to Step 11 if you wish to start a group call.
Note: You can implement both the Chat and Calls SDKs to your app. Two SDKs work on the same Sendbird application for them to share users. In this case, you can allow Calls to retrieve a list of users in the app by using the Chat SDK’s method or Chat API.
Make 1-to-1 call
Step 6 Add capabilities to your app
You can receive push notifications about an incoming 1-to-1 call with either VoIP notifications or remote notifications.
To receive notifications using VoIP notifications, add CallKit and PushKit. Then, go to your Xcode project’s Signing & Capabilities and enable Background Modes. Select the Voice over IP option under the list of available modes.
To receive notifications using remote notifications, go to your Xcode project’s Signing & Capabilities and enable Remote notifications.
Step 7 Add a device token
You can receive a 1-to-1 call by adding the user’s device token to the server. You can add the token for either VoIP notifications or remote notifications. Use the SendBirdCall.registerVoIPPush(token:completionHandler:)
method to add a device token for VoIP notifications. Use the SendBirdCall.registerRemotePush(token:completionHandler:)
method if you wish to add a token with remote notifications.
Note: To learn more about the differences between the two types of notifications, go to Notifications.
Step 8 Add event delegates
Sendbird Calls provides the SendBirdCallDelegate
and DirectCallDelegate
event delegates to handle events related to Direct call. SendBirdCallDelegate
is used to respond to device events such as incoming calls. DirectCallDelegate
is used to respond to call specific events such as call results.
- Add
SendBirdCallDelegate
by using theSendBirdCall.addDelegate(:)
method.
- Add
DirectCallDelegate
by usingcall.delegate
.
Step 9 Make a call
You are now ready to make your first 1-to-1 call. To make a call, pass the callee’s user ID as an argument to a parameter in the SendBirdCall.dial()
method. To choose initial call configuration such as audio or video capabilities, video settings and mute settings, use the CallOption
object.
Step 10 Receive a call
You can accept or decline an incoming call. To accept an incoming call, use the directCall.accept()
method. To decline the call, use the directCall.end()
method. When you accept the call, a media session will automatically be established by the Calls SDK.
The callee’s app receives an incoming call through either VoIP notifications or remote notifications. In order to receive incoming calls to the callee’s app, the received notification must be delivered to the Calls SDK through the SendBirdCall
instance.
To receive notifications using VoIP notifications, refer to the code below.
To receive notifications using remote notifications, refer to the code below.
Start a group call
Step 11 Create a room
When creating your first room for a group call, you can choose either a room that supports up to six participants with video or a room that supports up to 100 participants with audio. When the room is created, ROOM_ID
is generated.
-
Use the
RoomType
property to set the room type. -
Use the
createRoom()
method to create a room as shown below.
List of properties
Property name | Type | Description |
---|---|---|
type | RoomType | Specifies the type of the room. Valid values are the following. |
Step 12 Enter a room
You can now enter a room and start your first group call. When you enter a room, a participant is created with a unique participant ID to represent the user in the room.
To enter a room, you must acquire the room instance from the Sendbird server with the room ID. To fetch the most up-to-date room instance from the Sendbird server, use the SendBirdCall.fetchRoom(by:completionHandler:)
method. Also, you can use the SendBirdCall.getCachedRoom(by:)
method that returns the most recently cached room instance from Sendbird Calls SDK.
Note: A user can enter the room using multiple devices or browser tabs. Entering from each device or browser tab will create a new participant.
Once the room is retrieved, call the enter(with:completionHandler:)
method to enter the room.
Note: Share the room ID with other users for them to enter the room from the client app.