Package com.sinch.android.rtc
Interface SinchClient
-
public interface SinchClient
The SinchClient is the Sinch SDK entry point.It provides access to the feature classes in the Sinch SDK: CallClient, AudioController and VideoController. It is also used to configure the user's and device's capabilities.
The user IDs that are used to identify users application specific. If the app already has a scheme for user IDs (email addresses, phone numbers, customer numbers, etc.), the same ID could be used when configuring the SinchClient.
Example
// Instantiate a SinchClient android.content.Context context = this.getApplicationContext(); SinchClient sinchClient = Sinch.getSinchClientBuilder().context(context) .applicationKey("<application-key>") .environmentHost("ocra.api.sinch.com") .userId("<user id>") .build(); // Specify the client capabilities. ((SinchClientPrivate)sinchClient).setSupportActiveConnection(true); sinchClient.setSupportManagedPush(true); // Add the client listener that handles client state changes. sinchClient.addSinchClientListener(...); // Start the client sinchClient.start(); ... // Use the CallClient to place and receive calls // Stop listening for incoming calls. sinchClient.stopListeningOnActiveConnection(); // Stop the client when the calling functionality is no longer needed. sinchClient.terminateGracefully();
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addSinchClientListener(SinchClientListener sinchClientListener)
TheSinchClientListener
object handles events from theSinchClient
such as incoming calls.void
checkManifest()
This method should be called beforestart()
and be used during development time to verify that the manifest contains the permissions required.AudioController
getAudioController()
Returns anAudioController
object for controlling different audio settings.CallClient
getCallClient()
Returns theCallClient
object for placing and receiving calls.java.lang.String
getLocalUserId()
Returns the id of the user associated with thisSinchClient
.VideoController
getVideoController()
Returns aVideoController
object for managing and retrieving views for Video calls.boolean
isStarted()
Returnstrue
if theSinchClient
is started.NotificationResult
relayRemotePushNotificationPayload(android.content.Intent intent)
Method used to forward the intent received from FCM.NotificationResult
relayRemotePushNotificationPayload(java.lang.String payload)
Method used to forward the Sinch specific payload extracted from an incoming Google Cloud Messaging message.NotificationResult
relayRemotePushNotificationPayload(java.util.Map<java.lang.String,java.lang.String> payload)
Method used to forward the intent received from FCM.void
removeSinchClientListener(SinchClientListener sinchClientListener)
Remove listener for client events.void
setPushNotificationDisplayName(java.lang.String displayName)
Specify a display name to be used when the Sinch client sends a push notification on behalf of the local user (e.g.void
setSupportManagedPush(boolean enabled)
Enables the use of managed push, where Sinch is responsible for sending your app a push notification when necessary.void
start()
Starts the Sinch client.void
startListeningOnActiveConnection()
Start listening for incoming calls.void
stopListeningOnActiveConnection()
Stop listening for incoming calls.void
terminateGracefully()
Terminates the Sinch client, while still leaving it some time to finish up currently pending tasks, for example finishing pending HTTP requests.
-
-
-
Method Detail
-
setSupportManagedPush
void setSupportManagedPush(boolean enabled)
Enables the use of managed push, where Sinch is responsible for sending your app a push notification when necessary.- Parameters:
enabled
- whether or not managed push is enabled
-
checkManifest
void checkManifest()
This method should be called beforestart()
and be used during development time to verify that the manifest contains the permissions required. Once the application is ready to be published any calls to this manifest can be removed.- Throws:
MissingPermissionException
- if any of the required permissions are missing.
-
getCallClient
CallClient getCallClient()
Returns theCallClient
object for placing and receiving calls.- Returns:
- the
CallClient
object. - Throws:
java.lang.IllegalStateException
- if disposed.
-
addSinchClientListener
void addSinchClientListener(SinchClientListener sinchClientListener)
TheSinchClientListener
object handles events from theSinchClient
such as incoming calls.- Parameters:
sinchClientListener
- aSinchClientListener
-
removeSinchClientListener
void removeSinchClientListener(SinchClientListener sinchClientListener)
Remove listener for client events.- Parameters:
sinchClientListener
- aSinchClientListener
-
start
void start()
Starts the Sinch client. This must be done prior to making any calls or callingstartListening
.- Throws:
java.lang.IllegalStateException
- ifSinchClient
is already startedMissingPermissionException
- ifSinchClient
detects that the app lacks required Android permissions
-
isStarted
boolean isStarted()
Returnstrue
if theSinchClient
is started.- Returns:
true
if theSinchClient
is started.
-
terminateGracefully
void terminateGracefully()
Terminates the Sinch client, while still leaving it some time to finish up currently pending tasks, for example finishing pending HTTP requests.
-
startListeningOnActiveConnection
void startListeningOnActiveConnection()
Start listening for incoming calls.
-
stopListeningOnActiveConnection
void stopListeningOnActiveConnection()
Stop listening for incoming calls.
-
relayRemotePushNotificationPayload
NotificationResult relayRemotePushNotificationPayload(java.lang.String payload)
Method used to forward the Sinch specific payload extracted from an incoming Google Cloud Messaging message. This will implicitly start theSinchClient
if it wasn't already started.- Parameters:
payload
- Sinch specific payload which was transferred with the message- Returns:
- A result indicating initial inspection of the payload.
-
relayRemotePushNotificationPayload
NotificationResult relayRemotePushNotificationPayload(android.content.Intent intent)
Method used to forward the intent received from FCM. This will automatically extract the sinch specific payload, if available. This will implicitly start theSinchClient
if it wasn't already started.- Parameters:
intent
- Intent received from a FCM receiver- Returns:
- A result indicating initial inspection of the payload.
- See Also:
SinchHelpers.isSinchPushIntent(Intent)
,relayRemotePushNotificationPayload(String)
-
relayRemotePushNotificationPayload
NotificationResult relayRemotePushNotificationPayload(java.util.Map<java.lang.String,java.lang.String> payload)
Method used to forward the intent received from FCM. This will automatically extract the sinch specific payload, if available. This will implicitly start theSinchClient
if it wasn't already started.- Parameters:
payload
- Payload received from a FCM RemoteMessage data- Returns:
- A result indicating initial inspection of the payload.
- See Also:
SinchHelpers.isSinchPushPayload(java.util.Map)
,relayRemotePushNotificationPayload(String)
-
setPushNotificationDisplayName
void setPushNotificationDisplayName(java.lang.String displayName)
Specify a display name to be used when the Sinch client sends a push notification on behalf of the local user (e.g. for an outgoing call). This will only be used when usingsetSupportManagedPush(boolean)
). Display name is included in a push notification on a best-effort basis. For example, if the target device has very limited push payload size constraints (e.g iOS 7 can only handle 255 byte push notification payload), then the display name may not be included.- Parameters:
displayName
- display name may at most be 255 bytes (UTF-8 encoded) long.
-
getLocalUserId
java.lang.String getLocalUserId()
Returns the id of the user associated with thisSinchClient
.- Returns:
- the local user id.
-
getAudioController
AudioController getAudioController()
Returns anAudioController
object for controlling different audio settings. You may only call this method while theSinchClient
is started.- Returns:
- an
AudioController
object for controlling audio settings. - Throws:
java.lang.IllegalStateException
- ifSinchClient
isn't started.
-
getVideoController
VideoController getVideoController()
Returns aVideoController
object for managing and retrieving views for Video calls.- Returns:
- an
VideoController
object for controlling video settings.
-
-