-
Notifications
You must be signed in to change notification settings - Fork 3
InfobipRTC
-
enablePushNotification(_ token: String, deviceToken: String, debug: Bool, pushConfigId: String)
-
callWebrtc(_ callWebrtcRequest: CallWebrtcRequest) throws -> WebrtcCall
-
callPhone(_ callPhoneRequest: CallPhoneRequest) throws -> PhoneCall
-
callViber(_ callViberRequest: CallViberRequest) throws -> ViberCall
-
joinRoom(_ roomRequest: RoomRequest, _ roomCallOptions: RoomCallOptions) throws -> RoomCall
-
callApplication(_ callApplicationRequest: CallApplicationRequest) throws -> ApplicationCall
-
isIncomingApplicationCall(payload: [AnyHashable: Any]) -> Bool
-
handleIncomingCall(_ payload: PKPushPayload, _ incomingCallEventListener: IncomingCallEventListener)
-
handleIncomingApplicationCall(payload: [AnyHashable: Any], _ incomingApplicationCallEventListener: IncomingApplicationCallEventListener)
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. -
pushConfigId
:String
- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint.
N/A
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let infobipRTC = getInfobipRTCInstance()
let token = obtainToken()
let debug = isDebug()
if type == .voIP {
infobipRTC.enablePushNotification(token, pushCredentials: pushCredentials, debug: debug, pushConfigId: "454d142b-a1ad-239a-d231-227fa335aadc3")
}
}
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. -
pushConfigId
:String
- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint. -
completionHandler
:(EnablePushNotificationResult) -> Void
- Completion handler receivingEnablePushNotificationResult
.
N/A
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let infobipRTC = getInfobipRTCInstance()
let token = obtainToken()
let debug = isDebug()
if type == .voIP {
infobipRTC.enablePushNotification(token, pushCredentials: pushCredentials, debug: debug, pushConfigId: "454d142b-a1ad-239a-d231-227fa335aadc3") { 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. -
pushConfigId
:String
- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint.
N/A
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let infobipRTC = getInfobipRTCInstance()
let token = obtainToken()
let debug = isDebug()
if type == .voIP {
let deviceToken = pushCredentials.token.reduce("", {$0 - String(format: "%02X", $1)})
infobipRTC.enablePushNotification(token, deviceToken: deviceToken, debug: debug, pushConfigId: "454d142b-a1ad-239a-d231-227fa335aadc3")
}
}
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.
N/A
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if type == .voIP {
let token = obtainToken()
infobipRTC.disablePushNotification(token)
}
}
Makes an outgoing call to another user of Infobip's WebRTC platform.
-
callWebrtcRequest
:CallWebrtcRequest
- Object containing all information needed to make an outgoing call.
-
WebrtcCall
- Instance of theWebrtcCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating audio call
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callWebrtcRequest = CallWebrtcRequest(token, destination: "Alice", webrtcCallEventListener: self)
let webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest)
Makes an outgoing call to another user of Infobip's WebRTC platform, using additional options.
-
callWebrtcRequest
:CallWebrtcRequest
- Object containing all information needed to make an outgoing call. -
webrtcCallOptions
:WebrtcCallOptions
- Additional options used to configure an outgoing call.
-
WebrtcCall
- Instance of theWebrtcCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating video call
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callWebrtcRequest = CallWebrtcRequest(token, destination: "Alice", webrtcCallEventListener: self)
let webrtcCallOptions = WebrtcCallOptions(video: true)
let webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest, webrtcCallOptions)
Makes an outgoing call to a given phone number (physical device, connected to Public Switched Telephone Network, mobile or landline).
-
callPhoneRequest
:CallPhoneRequest
- Object containing all information needed to make an outgoing call.
-
PhoneCall
- Instance of thePhoneCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating call to a phone number
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callPhoneRequest = CallPhoneRequest(token, destination: "41793026727", phoneCallEventListener: self)
let call = infobipRTC.callPhone(callPhoneRequest)
Makes an outgoing call to a given phone number (physical device, connected to Public Switched Telephone Network, mobile or landline), using additional options.
-
callPhoneRequest
:CallPhoneRequest
- Object containing all information needed to make an outgoing call. -
phoneCallOptions
:PhoneCallOptions
- Additional options used to configure an outgoing call.
-
PhoneCall
- Instance of thePhoneCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating call to a phone number, with options
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callPhoneRequest = CallPhoneRequest(token, destination: "41793026727", phoneCallEventListener: self)
let phoneCallOptions = PhoneCallOptions(from: "33712345678")
let call = infobipRTC.callPhone(callPhoneRequest, phoneCallOptions)
Makes an outgoing call to a given Viber phone number.
-
callViberRequest
:CallViberRequest
- Object containing all information needed to make an outgoing call.
-
ViberCall
- Instance of theViberCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating call to a Viber destination
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callViberRequest = CallViberRequest(token, destination: "41793026727", from: "41727620397", viberCallEventListener: self)
let call = infobipRTC.callViber(callViberRequest)
Makes an outgoing call to a given Viber phone number, using additional options.
-
callViberRequest
:CallViberRequest
- Object containing all information needed to make an outgoing call. -
viberCallOptions
:ViberCallOptions
- Additional options used to configure an outgoing call.
-
ViberCall
- Instance of theViberCall
.
-
CallError
- Error explaining why making the call failed.
- Example of initiating call to a Viber destination, with options
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callViberRequest = CallViberRequest(token, destination: "41793026727", from: "41727620397", viberCallEventListener: self)
let viberCallOptions = ViberCallOptions(audio: true)
let call = infobipRTC.callViber(callViberRequest, viberCallOptions)
Joins a room on Infobip's WebRTC platform.
-
roomRequest
:RoomRequest
- Object containing all information needed to join a room.
-
RoomCall
- Instance of theRoomCall
.
-
CallError
- Error explaining why joining the room failed.
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let roomRequest = RoomRequest(token, roomName: "room-demo", roomCallEventListener: self)
let roomCall = infobipRTC.joinRoom(roomRequest)
Joins a room on Infobip's WebRTC platform, using additional options.
-
roomRequest
:RoomRequest
- Object containing all information needed to join a room. -
roomCallOptions
:RoomCallOptions
- Additional options used to configure a call.
-
RoomCall
- Instance of theRoomCall
.
-
CallError
- Error explaining why joining the room failed.
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let roomRequest = RoomRequest(token, roomName: "room-demo", roomCallEventListener: self)
let roomCallOptions = RoomCallOptions(video: true)
let roomCall = infobipRTC.joinRoom(roomRequest, roomCallOptions)
Makes an outgoing application call through Infobip's Calls platform to your application.
-
callApplicationRequest
:CallApplicationRequest
- Object containing all information needed to make an application call.
-
ApplicationCall
- Instance of theApplicationCall
.
- Example of initiating an application call:
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callApplicationRequest = CallApplicationRequest(token, callsConfigurationId: "45g2gql9ay4a2blu55uk1628", applicationCallEventListener: self)
let applicationCall = infobipRTC.callApplication(callApplicationRequest)
- Example of initiating a call towards the Infobip Conversations:
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callApplicationRequest = CallApplicationRequest(token, callsConfigurationId: InfobipCallsConfiguration.conversations.rawValue, applicationCallEventListener: self)
let applicationCall = infobipRTC.callApplication(callApplicationRequest)
Makes an outgoing application call through Infobip's Calls platform to your application, using additional options.
-
callApplicationRequest
:CallApplicationRequest
- Object containing all information needed to make an application call. -
applicationCallOptions
:ApplicationCallOptions
- Additional options used to configure an outgoing application call.
-
ApplicationCall
- Instance of theApplicationCall
.
- Example of initiating a video application call:
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callApplicationRequest = CallApplicationRequest(token, callsConfigurationId: "45g2gql9ay4a2blu55uk1628", applicationCallEventListener: self)
let applicationCallOptions = ApplicationCallOptions(video: false)
let applicationCall = infobipRTC.callApplication(callApplicationRequest, applicationCallOptions)
- Example of initiating a call towards the Infobip Conversations:
let token = obtainToken()
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
let callApplicationRequest = CallApplicationRequest(token, callsConfigurationId: InfobipCallsConfiguration.conversations.rawValue, applicationCallEventListener: self)
let applicationCall = infobipRTC.callApplication(callApplicationRequest)
Get currently active call if exists.
none
-
Call?
- Instance of the currently active call.nil
if there is no active call.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if let activeCall = infobipRTC.getActiveCall() {
activeCall.mute(true)
}
Get currently active room call if exists.
none
-
RoomCall?
- Instance of the currently active room call.nil
if there is no active room call.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if let activeRoomCall = infobipRTC.getActiveRoomCall() {
activeRoomCall.mute(true)
}
Get currently active application call if exists.
none
-
ApplicationCall?
- Instance of the currently active application call.nil
if there is no active application call.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
if let activeApplicationCall = infobipRTC.getActiveApplicationCall() {
activeApplicationCall.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
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if infobipRTC.isIncomingCall(payload) {
infobipRTC.handleIncomingCall(payload, incomingCallEventListener: self)
}
}
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
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
let dictionaryPayload = payload.dictionaryPayload
if infobipRTC.isIncomingCall(payload: dictionaryPayload) {
infobipRTC.handleIncomingCall(payload: dictionaryPayload, incomingCallEventListener: self)
}
}
Check if received VoIP push notification is incoming application call.
-
payload
:PKPushPayload
- PushKit Push Notification Payload.
-
Bool
-true
if VoIP push notification contains incoming application call data, otherwisefalse
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if infobipRTC.isIncomingApplicationCall(payload) {
infobipRTC.handleIncomingApplicationCall(payload, incomingApplicationCallEventListener: self)
}
}
Check if received VoIP push notification is incoming application call.
-
payload
:[AnyHashable: Any]
- PushKit Push Notification Payload represented as dictionary.
-
Bool
-true
if VoIP push notification contains incoming application call data, otherwisefalse
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
let dictionaryPayload = payload.dictionaryPayload
if infobipRTC.isIncomingApplicationCall(payload: dictionaryPayload) {
infobipRTC.handleIncomingApplicationCall(payload: dictionaryPayload, incomingApplicationCallEventListener: self)
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive incoming call.
-
payload
:PKPushPayload
- PushKit Push Notification Payload. -
incomingCallEventListener
:IncomingCallEventListener
- Instance of theIncomingCallEventListener
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if type == .voIP {
os_log("Received VoIP Push Notification %@", payload.dictionaryPayload)
if infobipRTC.isIncomingCall(payload) {
infobipRTC.handleIncomingCall(payload, incomingCallEventListener: self)
}
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive incoming call.
-
payload
:[AnyHashable: Any]
- PushKit Push Notification Payload represented as dictionary. -
incomingCallEventListener
:IncomingCallEventListener
- Instance of theIncomingCallEventListener
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
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 infobipRTC.isIncomingCall(payload: dictionaryPayload) {
infobipRTC.handleIncomingnCall(payload: dictionaryPayload, incomingCallEventListener: self)
}
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive incoming application call.
-
payload
:PKPushPayload
- PushKit Push Notification Payload. -
incomingApplicationCallEventListener
:IncomingApplicationCallEventListener
- Instance of theIncomingApplicationCallEventListener
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
if type == .voIP {
os_log("Received VoIP Push Notification %@", payload.dictionaryPayload)
if infobipRTC.isIncomingApplicationCall(payload) {
infobipRTC.handleIncomingApplicationCall(payload, incomingApplicationCallEventListener: self)
}
}
}
Handle received VoIP Push Notification with InfobipRTC in order to receive incoming application call.
-
payload
:[AnyHashable: Any]
- PushKit Push Notification Payload represented as dictionary. -
incomingApplicationCallEventListener
:IncomingApplicationCallEventListener
- Instance of theIncomingApplicationCallEventListener
.
let infobipRTC: InfobipRTC = getInfobipRTCInstance()
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 infobipRTC.isIncomingApplicationCall(payload: dictionaryPayload) {
infobipRTC.handleIncomingApplicationCall(payload: dictionaryPayload, incomingApplicationCallEventListener: self)
}
}
}