-
Notifications
You must be signed in to change notification settings - Fork 2
InfobipRTC
-
void enablePushNotification(String token, Context context, String pushConfigId
-
RoomCall joinRoom(RoomRequest request) throws MissingPermissionsException, IllegalStatusException
-
boolean isIncomingApplicationCall(Map<String, String> payload)
Starts listening for incoming calls using active WebSocket connection to Infobip WebRTC platform.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
context
:Context
- Instance of theandroid.content.Context
class. -
incomingCallEventListener
:IncomingCallEventListener
- Interface defining a method that will be executed once an incoming call event is received.
N/A
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
InfobipRTC infobipRTC = infobipRTC.getInstance();
infobipRTC.registerForActiveConnection(
token,
getApplicationContext(),
new IncomingCallEventListener() {
@Override
public void onIncomingCall(IncomingCallEvent incomingCallEvent) {
IncomingCall incomingCall = incomingCallEvent.getIncomingCall();
Log.d("WebRTC", "Received incoming call from: " + incomingCall.source());
incomingCall.setEventListener(new DefaultCallEventListener());
incomingCall.accept(); // or incomingCall.decline();
}
}
);
Starts listening for incoming application calls using active WebSocket connection to Infobip WebRTC platform.
-
token
:String
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
context
:Context
- Instance of theandroid.content.Context
class. -
incomingApplicationCallEventListener
:IncomingApplicationCallEventListener
- Interface defining a method that will be executed once an incoming application call event is received.
N/A
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
infobipRTC.registerForActiveConnection(
token,
getApplicationContext(),
new IncomingApplicationCallEventListener() {
@Override
public void onIncomingApplicationCall(IncomingApplicationCallEvent incomingApplicationCallEvent) {
IncomingApplicationCall incomingApplicationCall = incomingApplicationCallEvent.getIncomingApplicationCall();
Log.d("WebRTC", "Received incoming call from: " + incomingApplicationCall.from());
incomingApplicationCall.setEventListener(new DefaultApplicationCallEventListener());
incomingApplicationCall.accept(); // or incomingApplicationCall.decline();
}
}
);
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. -
context
:Context
- Instance of theandroid.content.Context
class. -
pushConfigId
:String
- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint.
N/A
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
infobipRTC.enablePushNotification(token, getApplicationContext(), "454d142b-a1ad-239a-d231-227fa335aadc3");
Enable push notifications on a physical device for incoming call events. Event listener 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. -
context
:Context
- Instance of theandroid.content.Context
class. -
pushConfigId
:String
- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint. -
listener
:EventListener<EnablePushNotificationResult>
- Listener receivingEnablePushNotificationResult
.
N/A
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
infobipRTC.enablePushNotification(
token,
getApplicationContext(),
"454d142b-a1ad-239a-d231-227fa335aadc3",
result -> Log.d("WebRTC", String.format("Push registration result: %s", result.getStatus()))
);
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. -
context
:Context
- Instance of theandroid.content.Context
class.
N/A
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
infobipRTC.disablePushNotification(token, getApplicationContext());
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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(token, getApplicationContext(), "Alice", new DefaultWebrtcCallEventListener());
WebrtcCall 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(token, getApplicationContext(), "Alice", new DefaultWebrtcCallEventListener());
WebrtcCallOptions webrtcCallOptions = WebrtcCallOptions.builder().video(true).build();
WebrtcCall 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallPhoneRequest callPhoneRequest = new CallPhoneRequest(token, getApplicationContext(), "41793026727", new DefaultPhoneCallEventListener());
PhoneCall phoneCall = 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallPhoneRequest callPhoneRequest = new CallPhoneRequest(token, getApplicationContext(), "41793026727", new DefaultPhoneCallEventListener());
PhoneCallOptions phoneCallOptions = PhoneCallOptions.builder().from("33755531044").build();
PhoneCall phoneCall = 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallViberRequest callViberRequest = new CallViberRequest(token, getApplicationContext(), "41727620397", "41793026727", new DefaultViberCallEventListener());
ViberCall viberCall = 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallViberRequest callViberRequest = new CallViberRequest(token, getApplicationContext(), "41727620397", "41793026727", new DefaultViberCallEventListener());
ViberCallOptions viberCallOptions = ViberCallOptions.builder().audio(true).build();
ViberCall viberCall = 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
RoomRequest roomRequest = new RoomRequest(token, getApplicationContext(), "room-test", new DefaultRoomCallEventListener());
RoomCall 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 room call
-
RoomCall
- Instance of theRoomCall
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
RoomRequest roomRequest = new RoomRequest(token, getApplicationContext(), "room-test", new DefaultRoomCallEventListener());
RoomCallOptions roomCallOptions = new RoomCallOptions.builder().video(true).build();
RoomCall 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
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
- example of initiating an application call
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallApplicationRequest callApplicationRequest = new CallApplicationRequest(token, getApplicationContext(), "45g2gql9ay4a2blu55uk1628", new DefaultApplicationCallEventListener());
ApplicationCall applicationCall = infobipRTC.callApplication(callApplicationRequest);
- example of initiating a call towards Infobip Conversations
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallApplicationRequest callApplicationRequest = new CallApplicationRequest(
token,
getApplicationContext(),
InfobipCallsConfiguration.CONVERSATIONS.getCallsConfiguration(),
new DefaultApplicationCallEventListener()
);
ApplicationCall applicationCall = infobipRTC.callApplication(callApplicationRequest);
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. -
applicationCallOptions
:ApplicationCallOptions
- Additional options used to configure an outgoing application call.
-
ApplicationCall
- Instance of theApplicationCall
.
-
MissingPermissionsException
- Error thrown when the required permission is not accepted. It contains a message describing the issue. -
IllegalStatusException
- Error thrown when required conditions are not fulfilled. It contains a message describing the issue. This exception can be thrown in the following scenarios:- the internet connection is not available
- destination number / identity is invalid
- there is already a call / conference in progress
- token used for authentication has expired or is invalid
- token needed for authentication was not provided
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
CallApplicationRequest callApplicationRequest = new CallApplicationRequest(token, getApplicationContext(), "45g2gql9ay4a2blu55uk1628", new DefaultApplicationCallEventListener());
ApplicationCallOptions applicationCallOptions = ApplicationCallOptions.builder().customData(Map.of("userId", "bgxy-as45-ddf3")).build();
ApplicationCall applicationCall = infobipRTC.callApplication(callApplicationRequest, applicationCallOptions);
Get currently active call if it exists.
none
-
Call
- Instance of the currently active call.null
if there is no active call.
InfobipRTC infobipRTC = InfobipRTC.getInstance();
Call activeCall = infobipRTC.getActiveCall();
Get currently active room call if it exists.
none
-
RoomCall
- Instance of the currently active room call.null
if there is no active room.
InfobipRTC infobipRTC = InfobipRTC.getInstance();
RoomCall roomCall = infobipRTC.getActiveRoomCall();
Get currently active application call if it exists.
none
-
ApplicationCall
- Instance of the currently active application call.null
if there is no active application call.
InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Check if received push notification is incoming call.
-
payload
:Map<String, String>
- Payload received in push notification.
-
boolean
-true
if push notification contains incoming call data, otherwisefalse
.
class FcmService extends FirebaseMessagingService {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> payload = remoteMessage.getData();
if (infobipRTC.isIncomingCall(payload)) {
// handle incoming call (see 'handleIncomingCall' method)
}
}
}
Handle received push notification with InfobipRTC in order to receive an incoming call. You should
use FirebaseMessagingService
to listen for push notifications. Upon receiving a message, make sure to check the message type before calling this
method.
-
payload
:Map<String, String>
- Payload received in push notification. -
context
:Context
- Instance of theandroid.content.Context
class. -
incomingCallEventListener
:IncomingCallEventListener
- Interface defining method that will be executed once an incoming call event has been received.
N/A
class FcmService extends FirebaseMessagingService {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> payload = remoteMessage.getData();
if (infobipRTC.isIncomingCall(payload)) {
infobipRTC.handleIncomingCall(
payload,
getAplicationContext(),
new IncomingCallEventListener() {
@Override
public void onIncomingCall(IncomingCallEvent incomingCallEvent) {
IncomingCall incomingCall = incomingCallEvent.getIncomingCall();
Log.d("WebRTC", "Received an incoming call from: " + incomingCall.source());
incomingCall.setEventListener(new DefaultCallEventListener());
incomingCall.accept(); // or incomingCall.decline();
}
}
);
}
}
}
Check if received push notification is an incoming application call.
-
payload
:Map<String, String>
- Payload received in push notification.
-
boolean
-true
if push notification contains incoming application call data, otherwisefalse
.
class FcmService extends FirebaseMessagingService {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> payload = remoteMessage.getData();
if (infobipRTC.isIncomingApplicationCall(payload)) {
// handle incoming application call (see 'handleIncomingApplicationCall' method)
}
}
}
Handle received push notification with InfobipRTC in order to receive an incoming application call. You should
use FirebaseMessagingService
to listen for push notifications. Upon receiving a message, make sure to check the message type before calling this
method.
-
payload
:Map<String, String>
- Payload received in push notification. -
context
:Context
- Instance of theandroid.content.Context
class. -
incomingApplicationCallEventListener
:IncomingApplicationCallEventListener
- Interface defining method that will be executed once an incoming application call event is received.
N/A
class FcmService extends FirebaseMessagingService {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> payload = remoteMessage.getData();
if (infobipRTC.isIncomingApplicationCall(payload)) {
infobipRTC.handleIncomingApplicationCall(
payload,
getAplicationContext(),
new IncomingApplicationCallEventListener() {
@Override
public void onIncomingApplicationCall(IncomingApplicationCallEvent incomingApplicationCallEvent) {
IncomingApplicationCall incomingApplicationCall = incomingApplicationCallEvent.getIncomingApplicationCall();
Log.d("WebRTC", "Received an incoming application call from: " + incomingApplicationCall.from());
incomingApplicationCall.setEventListener(new DefaultApplicationCallEventListener());
incomingApplicationCall.accept(); // or incomingApplicationCall.decline();
}
}
);
}
}
}
Gets a current instance of InfobipRTC if it exists, if not, creates a new InfobipRTC instance
none
-
InfobipRTC
- Instance of the InfobipRTC interface.
InfobipRTC infobipRTC = InfobipRTC.getInstance();