-
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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
incomingCallEventListener:IncomingCallEventListener- Interface defining a method that will be executed once an incoming call event is received.
N/A
private void example() {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
String token = obtainToken();
infobipRTC.registerForActiveConnection(
token,
getApplicationContext(),
(IncomingCallEventListener) incomingWebrtcCallEvent -> {
IncomingWebrtcCall incomingWebrtcCall = incomingWebrtcCallEvent.getIncomingWebrtcCall();
Log.d("InfobipRTC", "Received incoming webrtc call from: " + incomingWebrtcCall.source());
incomingWebrtcCall.setEventListener(new DefaultWebrtcCallEventListener());
incomingWebrtcCall.accept(); // or incomingWebrtcCall.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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
incomingApplicationCallEventListener:IncomingApplicationCallEventListener- Interface defining a method that will be executed once an incoming application call event is received.
N/A
private void example() {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
String token = obtainToken();
infobipRTC.registerForActiveConnection(
token,
getApplicationContext(),
(IncomingApplicationCallEventListener) incomingApplicationCallEvent -> {
IncomingApplicationCall incomingApplicationCall = incomingApplicationCallEvent.getIncomingApplicationCall();
Log.d("InfobipRTC", "Received incoming application 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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
pushConfigId:String- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint.
N/A
private void example() {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
String token = obtainToken();
infobipRTC.enablePushNotification(token, getApplicationContext(), "454d142b-a1ad-239a-d231-227fa335aadc3");
}Enable push notifications on a physical device for receiving incoming call events. The result of the operation is provided asynchronously.
-
token:String- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
context:Context- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
pushConfigId:String- Push configuration ID generated via Infobip's HTTP /webrtc/1/webrtc-push-config endpoint. -
listener:EventListener<EnablePushNotificationResult>- An event listener that is invoked withEnablePushNotificationResultonce the operation completes, providing the status and description of the push notification registration attempt.
N/A
private void example() {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
String token = obtainToken();
infobipRTC.enablePushNotification(
token,
getApplicationContext(),
"454d142b-a1ad-239a-d231-227fa335aadc3",
result -> Log.d("InfobipRTC", 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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application.
N/A
private void example() {
String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();
infobipRTC.disablePushNotification(token, getApplicationContext());
}Disable push notifications for the device. After this, the device will no longer be able to receive push notifications. The result of the operation is provided asynchronously.
-
token:String- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
context:Context- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
listener:EventListener<DisablePushNotificationResult>- An event listener that is invoked withDisablePushNotificationResultonce the operation completes, providing the status and description of the push notification unregistration attempt.
N/A
private void example() {
InfobipRTC infobipRTC = InfobipRTC.getInstance();
String token = obtainToken();
infobipRTC.disablePushNotification(
token,
getApplicationContext(),
result -> Log.d("InfobipRTC", String.format("Push unregistration result: %s", result.getStatus()))
);
}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(), new DefaultRoomCallEventListener(), "room-test");
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(), new DefaultRoomCallEventListener(), "room-test");
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.nullif 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.nullif 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.nullif 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-trueif 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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
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,
getApplicationContext(),
incomingWebrtcCallEvent -> {
IncomingWebrtcCall incomingWebrtcCall = incomingWebrtcCallEvent.getIncomingWebrtcCall();
Log.d("InfobipRTC", String.format("Received an incoming call from: %s", incomingWebrtcCall.source()));
incomingWebrtcCall.setEventListener(new DefaultWebrtcCallEventListener());
incomingWebrtcCall.accept(); // or incomingWebrtcCall.decline();
}
);
}
}
}Check if received push notification is an incoming application call.
-
payload:Map<String, String>- Payload received in push notification.
-
boolean-trueif 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- An instance of theandroid.content.Contextclass, which provides access to system services, resources, and application-specific data in an Android application. -
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,
getApplicationContext(),
incomingApplicationCallEvent -> {
IncomingApplicationCall incomingApplicationCall = incomingApplicationCallEvent.getIncomingApplicationCall();
Log.i("InfobipRTC", String.format("Received an incoming application call from: %s", 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();