-
Notifications
You must be signed in to change notification settings - Fork 0
InfobipRTC
enablePushNotification(_ token: String, pushCredentials: PKPushCredentials, debug: Bool = false)
enablePushNotification(_ token: String, pushCredentials: PKPushCredentials, debug: Bool = false, _ completionHandler: (EnablePushNotificationResult) -> Void)
enablePushNotification(_ token: String, deviceToken: String, debug: Bool = false)
disablePushNotification(_ token: String)
call(_ callRequest: CallRequest, _ callOptions: CallOptions = CallOptions()) throws -> OutgoingCall
callPhoneNumber(_ callRequest: CallRequest, _ callPhoneNumberOptions: CallPhoneNumberOptions = CallPhoneNumberOptions()) throws -> OutgoingCall
callConversations(_ callConversationsRequest: CallConversationsRequest, _ callOptions: CallOptions = CallOptions()) throws -> OutgoingCall
getActiveCall() -> Call?
getActiveConference() -> Conference?
isIncomingCall(_ payload: PKPushPayload) -> Bool
isIncomingCall(payload: [AnyHashable: Any]) -> Bool
handleIncomingCall(_ payload: PKPushPayload) -> IncomingCall?
handleIncomingCall(payload: [AnyHashable: Any]) -> IncomingCall?
-
joinConference(_ conferenceRequest: ConferenceRequest) throws -> Conference
Enable push notifications on a physical device for receiving incoming call events.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
pushCredentials
:PKPushCredentials
- PushKit Push credentials received upon successful PushKit Push Registry init. -
debug
:Bool
- Optional flag used to distinguish Push Notifications environments(sandbox, production).false
by default.
none
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
if type == .voIP {
do {
let token = obtainToken()
#if DEBUG
try InfobipRTC.enablePushNotification(token, pushCredentials: pushCredentials, debug: true)
#else
try InfobipRTC.enablePushNotification(token, pushCredentials: pushCredentials)
#endif
} catch {
os_log("Failed to enable push notifications: %@", error.localizedDescription)
}
}
}
Enable push notifications on a physical device for incoming call events. Completion handler passed as the last parameter is used to observe whether the registration for push notifications was successful or not.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
pushCredentials
:PKPushCredentials
- PushKit Push credentials received upon successful PushKit Push Registry init. -
debug
:Bool
-Optional flag used to distinguish Push Notifications environments(sandbox, production).false
by default. -
completionHandler
:(EnablePushNotificationResult) -> Void
- Completion handler receivingEnablePushNotificationResult
.
none
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
if type == .voIP {
let token = obtainToken()
let debug = isDebug()
InfobipRTC.enablePushNotification(token, pushCredentials: pushCredentials, debug: debug) { result in
if result.status == .SUCCESS {
os_log("Successfully registered for push notifications.")
} else {
os_log("Failed to register for push notifications: %@", result.message)
}
}
}
}
Enable push notifications on a physical device for receiving incoming call events.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
deviceToken
:String
- Device token obtained from PushKit Push credentials you received upon successful PushKit Push Registry init. -
debug
:Bool
- Optional flag used to distinguish Push Notifications environments(sandbox, production).false
by default.
none
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
if type == .voIP {
do {
let token = obtainToken()
let deviceToken = pushCredentials.token.reduce("", {$0 - String(format: "%02X", $1)})
#if DEBUG
try InfobipRTC.enablePushNotification(token, deviceToken: deviceToken, debug: true)
#else
try InfobipRTC.enablePushNotification(token, deviceToken: deviceToken)
#endif
} catch {
os_log("Failed to enable push notifications: %@", error.localizedDescription)
}
}
}
Disable push notifications for the device. After this, the device will no longer be able to receive push notifications.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint.
none
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
if type == .voIP {
do {
let token = obtainToken()
try InfobipRTC.disablePushNotification(token)
} catch {
os_log("Failed to disable push notifications.")
}
}
}
Makes an outgoing call to another user of Infobip's WebRTC platform.
-
callRequest
:CallRequest
- Object containing all information needed to make an outgoing call. -
callOptions
:CallOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating audio call
let token = obtainToken()
let callRequest = CallRequest(token, destination: "Alice", callDelegate: self)
let callOptions = CallOptions(video: false)
let call = InfobipRTC.call(callRequest, callOptions)
- Example of initiating video call with recording turned on
let token = obtainToken()
let callRequest = CallRequest(token, destination: "Alice", callDelegate: self)
let recordingOptions = RecordingOptions(true, true)
let callOptions = CallOptions(video: true, recordingOptions: recordingOptions)
let call = InfobipRTC.call(callRequest, callOptions)
Makes an outgoing call to a given phone number (physical device, connected to Public Switched Telephone Network, mobile or landline).
-
callRequest
:CallRequest
- Object containing all information needed to make an outgoing call. -
callPhoneNumberOptions
:CallPhoneNumberOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating call to a phone number
let token = obtainToken()
let callRequest = CallRequest(token, "41793026727", callDelegate: self)
let callPhoneNumberOptions = CallPhoneNumberOptions(from: "33755531044")
let call = InfobipRTC.callPhoneNumber(callRequest, callPhoneNumberOptions)
- Example of initiating call to a phone number with recording turned on
let token = obtainToken()
let callRequest = CallRequest(token, "41793026727", callDelegate: self)
let recordingOptions = RecordingOptions(true)
let callPhoneNumberOptions = CallPhoneNumberOptions(from: "33755531044", recordingOptions: recordingOptions)
let call = InfobipRTC.call(callRequest, callPhoneNumberOptions)
Makes an outgoing call to Infobip Conversations platform.
-
callConversationsRequest
:CallConversationsRequest
- Object containing all information needed to make an outgoing call. -
callOptions
:CallOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating a call to Conversations
let token = obtainToken()
let callConversationsRequest = CallConversationsRequest(token, self)
let call = infobipRTC.callConversations(callConversationsRequest)
- Example of initiating a call to Conversations with recording turned on
let token = obtainToken()
let callConversationsRequest = CallConversationsRequest(token, self)
let recordingOptions = RecordingOptions(true, true)
let callOptions = CallOptions(video: true, recordingOptions: recordingOptions)
let call = InfobipRTC.call(callConversationsRequest, callOptions)
Get currently active call if exists.
none
-
Call?
- Instance of the currently active call.nil
if there is no active call.
if let activeCall = InfobipRTC.getActiveCall() {
activeCall.mute(true)
}
Get currently active conference if exists.
none
-
Conference?
- Instance of the currently active conference.nil
if there is no active conference.
if let activeConference = InfobipRTC.getActiveConference() {
getActiveConference.mute(true)
}
Check if received VoIP push notification is incoming call.
-
payload
:PKPushPayload
- PushKit Push Notification Payload.
-
Bool
-true
if VoIP push notification contains incoming call data, otherwisefalse
.
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if InfobipRTC.isIncomingCall(payload) {
InfobipRTC.handleIncomingCall(payload)
}
}
Check if received VoIP push notification is incoming call.
-
payload
:[AnyHashable: Any]
- PushKit Push Notification Payload represented as dictionary.
-
Bool
-true
if VoIP push notification contains incoming call data, otherwisefalse
.
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
let dictionaryPayload = payload.dictionaryPayload
if InfobipRTC.isIncomingCall(payload: dictionaryPayload) {
InfobipRTC.handleIncomingCall(payload: dictionaryPayload)
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive Incoming Call.
-
payload
:PKPushPayload
- PushKit Push Notification Payload.
-
IncomingCall?
- Instance of the incoming call if any ornil
.
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if type == .voIP {
os_log("Received VoIP Push Notification %@", payload.dictionaryPayload)
if let incomingCall = InfobipRTC.handleIncomingCall(payload) {
...
}
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive Incoming Call.
-
payload
:[AnyHashable: Any]
- PushKit Push Notification Payload represented as dictionary.
-
IncomingCall?
- Instance of the incoming call if any ornil
.
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if type == .voIP {
let dictionaryPayload = payload.dictionaryPayload
os_log("Received VoIP Push Notification %@", dictionaryPayload)
if let incomingCall = InfobipRTC.handleIncomingCall(payload: dictionaryPayload) {
...
}
}
}
Joins a conference call on Infobip's WebRTC platform.
-
conferenceRequest
:ConferenceRequest
- Object containing all information needed to join a conference.
-
Conference
- Instance of theConference
.
-
ConferenceError
- Error explaining why joining the conference call failed.
let token = obtainToken()
let conferenceRequest = ConferenceRequest(token, "conference-demo", self)
let conference = InfobipRTC.joinConference(conferenceRequest)
- Prerequisites
- Events
- InfobipRTC
- Call
- IncomingCall
- OutgoingCall
- CallRequest
- CallConversationsRequest
- CallOptions
- VideoOptions
- VideoTrack
- RecordingOptions
- CameraOrientation
- CallPhoneNumberOptions
- CallStatus
- CallError
- DTMFError
- ErrorCode
- RTCUser
- CallDelegate
- CallRingingEvent
- CallEstablishedEvent
- CallUpdatedEvent
- CallHangupEvent
- CallErrorEvent
- InfobipSimulator
- Conference
- ConferenceDelegate
- ConferenceRequest
- ConferenceStatus
- ConferenceError
- ConferenceUser
- NetworkQuality
- NetworkQualityChangedEvent
- NetworkQualityDelegate