SendBirdCall
@objcMembers
@objc(SBCSendBirdCall)
public class SendBirdCall : NSObject
SendBirdCall
-
The app id of your SendBirdCalls application. Configure the app id using configure(appId:). This is get-only property.
Important
If you change the app ID, a previous configured app ID will be removed and all calls will be canceled.SendBirdCall.appId // "Optional(YOUR_APP_ID)"Since
1.0.0Declaration
Swift
public static var appId: String? { get } -
Initiate
SendBirdCallinstance when a client app is launched. If another initialization with anotherAPP_IDtakes place, all existing data will be deleted and theSendBirdCallinstance will be initialized with the newAPP_ID.SendBirdCall.configure(appId: "YOUR_APP_ID")Since
1.0.0
Tag: configure(appId)
Declaration
Swift
@discardableResult public static func configure(appId: String) -> BoolParameters
appIdYour own app ID from your dashboard
Return Value
(Discardable)
Boolvalue. If the paramter has an empty string or equal previous app ID, it returnsfalse. If the method configures app ID successfully, it returnstrue. -
SendBirdCalls SDK Version
self.versionLabel.text = "SendBirdCalls v\(SendBirdCall.sdkVersion)" // "SendBirdCalls v1.0.0"Since
1.0.0Declaration
Swift
public static var sdkVersion: String { get }
-
Provides a view that allows user to change the system audio route. Returns AVRoutePickerView in iOS 11 or later and MPVolumeView in earlier iOS version.
let routePickerView = SendBirdCall.routePickerView(frame: frame) self.parentView.addSubView(routePickerView)- Customization
if #available(iOS 11.0, *) { guard let routePickerView = routePickerView as? AVRoutePickerView else { return } // Set up AVRoutePickerView } else { guard let routePickerView = routePickerView as? MPVolumeView else { return } // Set up MPVolumeView }Since
1.0.0
Tag: routePickerView(frame)
Declaration
Swift
public static func routePickerView(frame: CGRect) -> UIViewParameters
frameCGRectvalue that is assigned to view’s frame.Return Value
AVRoutePickerView in iOS 11.0 or later. (MPVolumeView in previous iOS version)
-
Specifies the queue that you want to use for callbacks and delegate methods
Since
1.0.0
Declaration
Swift
public static func executeOn(queue: DispatchQueue)Parameters
queueDispatchQueue that will be used when callbacks and delegates are called.
-
Registers a device-specific
SendBirdCallDelegateevent handler. Responding to device-wide events (e.g. incoming calls) is then managed as shown below:SendBirdCall.addDelegate(self, identifier: UNIQUE_HANDLER_ID) func didStartRinging(_ call: DirectCall) { call.delegate = self }Since
1.0.0Declaration
Swift
public static func addDelegate(_ delegate: SendBirdCallDelegate, identifier: String)Parameters
delegateSendBirdCallDelegate that listens to SendBirdCall events
identifierIdentifier for the specific delegate
-
Removes delegate for the given identifier.
Since
1.0.0
Declaration
Swift
public static func removeDelegate(identifier: String)Parameters
identifierString identifier for the delegate. If SendBirdCall doesn’t have the given identifier, it will be ignored.
-
Removes all delegate for SendBirdCall events.
Since
1.0.0Declaration
Swift
public static func removeAllDelegates() -
Adds a
SendBirdRecordingDelegateto the SDK which is invoked when a recording session is finished successfully.SendBirdCall.addRecordingDelegate(self, identifier: UNIQUE_HANDLER_ID) func didSaveRecording(call: DirectCall, recordingId: String, options: RecordingOptions, outputURL: URL) { // Handle successful recording } func didFailToSaveRecording(call: DirectCall, recordingId: String, error: SBCError) { // Handle failed recording }Since
1.3.0Declaration
Swift
public static func addRecordingDelegate(_ delegate: SendBirdRecordingDelegate, identifier: String)Parameters
delegateA
RecordingDelegateto add to the SDK.identifierA unique identifier for the
RecordingDelegate. -
Removes a
SendBirdRecordingDelegatethat has the specified identifier from the SDK.Since
1.3.0Declaration
Swift
public static func removeRecordingDelegate(identifier: String)Parameters
identifierA unique identifier of a
RecordingDelegateto remove from the SDK. -
Removes all
SendBirdRecordingDelegatesfrom the SDK.Since
1.3.0Declaration
Swift
public static func removeAllRecordingDelegates()
-
Returns call for call ID.
Since
1.0.0
Declaration
Swift
@objc(callForCallId:) public static func getCall(forCallId callId: String) -> DirectCall?Parameters
callIdCall ID.
Return Value
DirectCallobject with corresponding call ID. It can benil. -
Returns call for a given UUID.
Declaration
Swift
@objc(callForUUID:) public static func getCall(forUUID callUUID: UUID) -> DirectCall?Parameters
callUUIDCall UUID.
Return Value
DirectCallobject with corresponding call ID. It can benil.- callUUID: Call UUID.
Since
1.0.0 -
Returns number of ongoing calls.
Since
1.2.0Declaration
Swift
public static func getOngoingCallCount() -> Int -
Returns all ongoing calls, including the active call and all calls on hold.
Since
1.8.0Declaration
Swift
public static func getOngoingCalls() -> [DirectCall]
-
Returns the currently authenticated user.
Since
1.0.0
Declaration
Swift
public static var currentUser: User? { get }Return Value
User that is currently authenticated. Returns nil if no user exists.
-
Authenticates user with user ID and access token that you generated at SendBird Dashboard. In order to make and receive calls, authenticate the user with SendBird server with the the
SendBirdCall.authenticate()method.let params = AuthenticateParams(userId: userId, accessToken: accessToken) SendBirdCall.authenticate(with: params) { user, error in guard let user = user, error == nil else { return } }Since
1.0.0- Tag: authenticate(with,completionHandler)
Declaration
Swift
@objc(authenticateWithParams:completionHandler:) public static func authenticate(with params: AuthenticateParams, completionHandler: @escaping AuthenticateHandler)Parameters
paramsAuthenticateParamsthat contains User Id, Access Token, Push Token, and UniquecompletionHandlerThe handler to call when the authenication is complete.
-
Deauthenticates user. To stop receiving calls after deauthentication, you should unregister according push tokens by calling
unregisterVoIPPushandunregisterRemotePushbefore deauthenticating.SendBirdCall.unregisterVoIPPush(token: myVoIPPushToken) { error in // Unregister push tokens to stop receiving push notifications on deauhtenticated devices. Unregistering push tokens must be done before deauthenticating. // Handle unregister push token SendBirdCall.deauthenticate { error in guard error == nil else { // handle error return } ) }Since
1.1.0Declaration
Swift
public static func deauthenticate(completionHandler: ErrorHandler?)Parameters
completionHandlerError Handler to be called after deauthenticate process is finished
-
Makes a call to user(callee) directly. (1:1 Call). Use the
CallOptionsobject to choose initial call configuration (e.g. muted/unmuted)let params = DialParams(calleeId: CALLEE_ID, callOptions: CallOptions()) let directCall = SendBirdCall.dial(with: params) { directCall, error in // } directCall.delegate = selfSince
1.0.0- Tag: dial(with,completionHandler)
Declaration
Swift
@discardableResult @objc(dialWithParams:completionHandler:) public static func dial(with params: DialParams, completionHandler: @escaping DirectCallHandler) -> DirectCall?Parameters
paramsDialParamsthat contains calleeId, videoCall flag, CallOptions, and customItems.completionHandlerCallback completionHandler to be called after dialing.
Return Value
(Discardable)
DirectCallobject. If the method failed to make a call, it would returnnil.
-
Sets timeout value for the timeout period before unanswered ringing or dialing calls expires and ends. Its default value is 60 seconds.
Important
If you assign invalid value(0 or negative value), it will be ignored
SendBirdCall.setRingingTimeout(30)Since
1.0.5Declaration
Swift
public static func setRingingTimeout(_ timeout: Int)Parameters
timeoutTimeout value in seconds.
-
Sets timeout value for the timeout period before the call is connected. Default value is 60 seconds.
Important
If you assign invalid value(0 or negative value), it will be ignored.
SendBirdCall.setCallConnectingTimeout(30)Since
1.2.0Declaration
Swift
public static func setCallConnectingTimeout(_ timeout: Int)Parameters
timeoutTimeout value in seconds.
-
Handles incoming VoIP push with SendBirdCalls payload. Incoming calls are received either via the application’s persistent internal server connection, or (if the application is in the background) via PushKit. PushKit messages received by the SendBirdCall instance MUST be delivered to the SDK.
class MyClass: PKPushRegistryDelegate { func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { SendBirdCall.pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type) { uuid in // IMPORTANT: You MUST report incoming call to CallKit when you receive a pushkit push. let provider = CXProvider(configuration: CXProviderConfiguration) let update = CXCallUpdate() update.remoteHandle = CXHandle(type: .generic, value: HANDLE_VALUE) provider.reportNewIncomingCall(with: uuid, update: update) { error in completion() }) } } }Since
1.0.0Declaration
Swift
public static func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completionHandler: PushRegistryHandler?)Parameters
registryPKPushRegistryobject same asPKPushRegistryDelegateregistry.payloadPKPushPayloadin incoming VoIP push notification.typePKPushTypeof push(VoIP)completionHandlerThis closure is invoked with
UUIDfrom the payload. -
To receive native-like calls while an app is in the background or closed, a device registration token must be registered to the server. Register a device push token during authentication by either providing it as a parameter in the
SendBirdCall.authenticate()method, or after authentication has completed using theSendBirdCall.registerVoIPPushToken()method.// PKPushRegistryDelegate class AppDelegate: PKPushRegistryDelegate { func voipRegistration() { self.voipRegistry = PKPushRegistry(queue: DispatchQueue.main) self.voipRegistry?.delegate = self self.voipRegistry?.desiredPushTypes = [.voIP] } ... func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { SendBirdCall.registerVoIPPush(token: pushCredentials.token) { (error) in guard let error = error else { return } // The Push Token has been registered successfully } } ... }Since
1.0.0- Tag: registerVoIPPush(token,unique,completionHandler)
Declaration
Swift
public static func registerVoIPPush(token: Data?, unique: Bool = false, completionHandler: ErrorHandler?)Parameters
tokenDataobject frompushCredential.token. Refer toPKPushRegistryDelegateuniqueIf it is false, you can register more token for multi devices. It has
falseas a default value. -
Unregisters a VoIP push token of specific device. You will not receive VoIP push notification for a call anymore. If you don’t want to receive a call in all of the devices of the users, call
unregisterAllVoIPPushTokens(completionHandler:).func removeVoIPPushToken() { SendBirdCall.unregisterVoIPPush(token: myVoIPPushToken) { error in guard error == nil else { return } // Unregistered successfully }Since
1.0.0- Tag: unregisterVoIPPush(token,completionHandler)
Declaration
Swift
public static func unregisterVoIPPush(token: Data?, completionHandler: ErrorHandler?)Parameters
tokenOptional Data for the push token that you want to unregister
completionHandlerErrorHandler that returns callback with error.
-
Unregister all VoIP push token registered to the current user(multi device). You will not receive a call in all of the devices of the users.
func removeAllOfVoIPPushTokens() { func unregisterAllVoIPPushTokens(completionHandler: ErrorHandler?) { guard error == nil else { return } // Unregistered all push tokens successfully } }Since
1.0.0Declaration
Swift
public static func unregisterAllVoIPPushTokens(completionHandler: ErrorHandler?)Parameters
completionHandlerErrorHandler that returns callback with error
-
To receive remote notifications when the app is in the background or closed, you must deliver the received remote notification to SendBirdCalls SDK.
Note
SendBirdCall will only process SendBird’s notifications. If the userInfo does not contain SendBirdCall’s payload, method will be returned without processing the payload so that you can control the push notifications at your will.
class AppDelegate { func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { SendBirdCall.application(application, didReceiveRemoteNotification: userInfo) } }Since
1.0.3Declaration
Swift
public static func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any])Parameters
applicationYour singleton app object.
userInfoA dictionary that contains information about incoming SendBird Calls.
-
To receive remote notifications while an app is in the background or closed, a device registration token must be registered to the server. Register a remote push token during by using the
SendBirdCall.registerRemotePushToken()method.func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { SendBirdCall.registerRemotePush(token: deviceToken) { error in // } }Note
You must register the device to receive remote notifications via Apple Push Notification service for
application(_:didRegisterForRemoteNotificationsWithDeviceToken:)to be called. Refer toUIApplication.registerForRemoteNotifications().Since
1.0.3
Tag: registerRemotePush(token:unique:completionHandler:)
Declaration
Swift
public static func registerRemotePush(token: Data?, unique: Bool = false, completionHandler: ErrorHandler?)Parameters
tokenUnique Token that identifies the device to APNs. Provide the token to register to SendBird.
uniqueIf it is false, you can register more token for multi devices. It has
falseas a default value. -
Unregisters a remote push token of specific device. You will not receive remote push notification on the device anymore. If you don’t want to receive remote notifications in all of the devices of the users, call
unregisterAllRemotePushTokens(completionHandler:).- token: Optional Data for the push token that you want to unregister
- completionHandler: ErrorHandler that returns callback with error.
func removeRemotePushToken() { SendBirdCall.unregisterRemotePush(token: myRemotePushToken) { error in guard error == nil else { return } // Unregistered successfully } }Since
1.0.3
Tag: unregisterRemotePush(token,completionHandler)
Declaration
Swift
public static func unregisterRemotePush(token: Data?, completionHandler: ErrorHandler?) -
Unregister all remote push token registered to the current user(multi device). You will not receive remote notifications in all of the devices of the users.
func removeAllOfRemotePushTokens() { func unregisterAllRemotePushTokens(completionHandler: ErrorHandler?) { guard error == nil else { return } // Unregistered all remote push tokens successfully } }Since
1.0.3Declaration
Swift
public static func unregisterAllRemotePushTokens(completionHandler: ErrorHandler?)Parameters
completionHandlerErrorHandler that returns callback with error
-
Creates a Direct Call Log List Query from given params.
Since
1.0.0
Declaration
Swift
@objc(createDirectCallLogListQueryWithParams:) public static func createDirectCallLogListQuery(with params: DirectCallLogListQuery.Params) -> DirectCallLogListQuery?Parameters
paramsDirectCallLogListQuery Params with options for creating query.
Return Value
DirectCallLogListQuery: Returns optional query object. Returns nil if current user does not exit.
-
Creates a query for room list with specified parameters.
Since
1.7.0Declaration
Swift
public static func createRoomListQuery(with params: RoomListQuery.Params) -> RoomListQuery?Parameters
paramsRoomListQuery Params with options for creating query.
-
Updates custom items for a given call Id.
Since
1.0.0
Declaration
Swift
public static func updateCustomItems(callId: String, customItems: [String : String], completionHandler: @escaping CustomItemsHandler)Parameters
callIdCall ID.
customItemsCustom items of [String: String] to be updated or inserted.
completionHandlerCallback completionHandler. Contains custom items, changes custom items, and error.
-
Deletes custom items for a given call Id.
Since
1.0.0
Declaration
Swift
public static func deleteCustomItems(callId: String, customItemKeys: [String], completionHandler: @escaping CustomItemsHandler)Parameters
callIdCall ID.
customItemKeysKeys of custom items that you want to delete.
completionHandlerCallback completionHandler. Contains custom items, changes custom items, and error.
-
Deletes all custom items for a given call Id.
Since
1.0.0
Declaration
Swift
public static func deleteAllCustomItems(callId: String, completionHandler: @escaping CustomItemsHandler)Parameters
callIdCall ID.
completionHandlerCallback completionHandler. Contains custom items, changes custom items, and error.
-
Called when the audio session is activated outside of the app by iOS.
class AppDelegate: CXProviderDelegate { func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) { SendBirdCall.audioSessionDidActivate(audioSession) } } // MARK: - Audio SessionSince
1.0.2Declaration
Swift
public static func audioSessionDidActivate(_ audioSession: AVAudioSession) -
Called when the audio session is deactivated outside of the app by iOS.
class AppDelegate: CXProviderDelegate { func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) { SendBirdCall.audioSessionDidDeactivate(audioSession) } }Since
1.0.2Declaration
Swift
public static func audioSessionDidDeactivate(_ audioSession: AVAudioSession) -
Adds sound used in
DirectCallsuch as ringtone and some sound effects with its file name and bundle.SendBirdCall.addDirectCallSound("dialing.mp3", forType: .dialing)Since
1.3.0
Declaration
Swift
public static func addDirectCallSound(_ name: String, bundle: Bundle = .main, forType type: SoundType)Parameters
nameThe name of your audio file. Please explicit its extension: “dialing.mp3”
bundleThe bundle object. The default is main bundle.
typeThe type of sound.
-
Enables / disables dial sound used in
DirectCalleven when the device is in silent mode. Call this method right afteraddDirectCallSound(_:forType:).SendBirdCall.addDirectCallSound("dialing.mp3", forType: .dialing) SendBirdCall.setDirectCallDialingSoundOnWhenSilentMode(isEnabled: true) // Will play dial direct call sounds in silent modeSince
1.5.0
Declaration
Swift
@objc(setDirectCallDialingSoundOnWhenSilentMode:) public static func setDirectCallDialingSoundOnWhenSilentMode(isEnabled: Bool)Parameters
isEnabledIf it is
true, dial sound used inDirectCallwill be played in silent mode. -
Adds sound used in
DirectCallsuch as ringtone and some sound effects with URL. If you use bundle to play sound,addDirectCallSound(_:bundle:forType:)is recommended.SendBirdCall.addDirectCallSound("dialing.mp3", forType: .dialing)Since
1.3.0
Declaration
Swift
public static func addDirectCallSound(_ url: URL, forType type: SoundType)Parameters
urlThe URL of your audio file.
typeThe key respresenting the type of sound.
-
Removes sound used in
DirectCallwithSoundTypevalue.SendBirdCall.removeDirectCallSound(forType: .dialing)Since
1.3.0
Declaration
Swift
public static func removeDirectCallSound(forType type: SoundType)Parameters
typeThe type of sound you want to remove.
-
Creates a room for group calls.
SendBirdCall.createRoom { room, error in ... // Set up delegate to receive events }Since
1.6.0
Tag: createRoom(with:completionHandler:)
Declaration
Swift
@objc(createRoomWithParams:completionHandler:) public static func createRoom(with params: RoomParams, completionHandler: @escaping RoomHandler)Parameters
completionHandlerA callback function that receives information about a room or an error from Sendbird server.
-
Fetches a room instance from Sendbird server.
Since
1.6.0
Declaration
Swift
@objc(fetchRoomByRoomId:completionHandler:) public static func fetchRoom(by roomId: String, completionHandler: @escaping RoomHandler)Parameters
roomIdroom ID.
completionHandlerCallback to be called after get
Roomobject corresponding the ID or an error
View on GitHub
SendBirdCall Class Reference