public interface SinchClient
It provides access to the feature classes in the Sinch SDK: MessageClient, CallClient and AudioController. 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.
// Instantiate a SinchClient
android.content.Context context = this.getApplicationContext();
SinchClient sinchClient = Sinch.getSinchClientBuilder().context(context)
.applicationKey("<application-key>")
.applicationSecret("<application-secret>")
.environmentHost("sandbox.sinch.com")
.userId("<user id>")
.build();
// Specify the client capabilities. At least one of the messaging or calling capabilities should be enabled.
sinchClient.setSupportMessaging(true);
sinchClient.setSupportCalling(true);
sinchClient.setSupportActiveConnectionInBackground(true);
sinchClient.setSupportPushNotifications(true);
// Add the client listener that handles client state changes.
sinchClient.addSinchClientListener(...);
// Start the client
sinchClient.start();
...
// Use the MessageClient to send and receive messages
// Use the CallClient to place and receive calls
// Stop listening for incoming events (calls or messages).
sinchClient.stopListeningOnActiveConnection();
// Stop the client when the calling or messaging functionality is no longer needed.
sinchClient.stop();
Modifier and Type | Method and Description |
---|---|
void |
addSinchClientListener(SinchClientListener sinchClientListener)
The
SinchClientListener object handles events from the
SinchClient such as incoming calls. |
void |
checkManifest()
This method should be called before
start() and be used during
development time to verify that the manifest contains the permissions
required. |
AudioController |
getAudioController()
Returns an
AudioController object for controlling different audio
settings. |
CallClient |
getCallClient()
Returns the
CallClient object for placing and receiving calls. |
java.lang.String |
getLocalUserId()
Returns the id of the user associated with this
SinchClient . |
MessageClient |
getMessageClient()
Deprecated.
Instant Messaging no longer supported.
|
VideoController |
getVideoController()
Returns a
VideoController object for managing and retrieving views for Video calls. |
boolean |
isStarted()
Returns
true if the SinchClient is started. |
void |
registerPushNotificationData(byte[] pushNotificationData)
Register device specific data that can be used to identify this device
and tie it to a GCM registration identifier.
|
NotificationResult |
relayRemotePushNotificationPayload(android.content.Intent intent)
Method used to forward the intent received from GCM.
|
NotificationResult |
relayRemotePushNotificationPayload(java.util.Map<java.lang.String,java.lang.String> payload)
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.
|
void |
removeSinchClientListener(SinchClientListener sinchClientListener)
Remove listener for client events.
|
void |
setMediaHandover(boolean enable)
Enables and disables media handover functionality.
|
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 |
setSupportActiveConnectionInBackground(boolean supported)
If you intend to listen for incoming calls in a background service of
some sort you must enable this.
|
void |
setSupportCalling(boolean supported)
If you intend to make or receive calls you must enable this.
|
void |
setSupportManagedPush(boolean enabled)
Enables the use of managed push, where Sinch is responsible for sending your app a push notification when
necessary.
|
void |
setSupportMessaging(boolean supported)
If you intend to send and/or receive messages you must enable this.
|
void |
setSupportPushNotifications(boolean supported)
If you implement support for push notifications, such as GCM, you must
enable this.
|
void |
start()
Starts the Sinch client.
|
void |
startListeningOnActiveConnection()
Start listening for incoming calls.
|
void |
stop()
Deprecated.
As of release 3.0.1, replaced by
terminate() |
void |
stopListeningOnActiveConnection()
Stop listening for incoming calls.
|
void |
terminate()
Terminates the Sinch client.
|
void |
terminateGracefully()
Terminates the Sinch client, while still leaving it some time to finish up currently
pending tasks, for example finishing pending HTTP requests.
|
void |
unregisterManagedPush()
Deprecated.
|
void |
unregisterPushNotificationData()
Unregister previously registered device specific data that is used to
identify this device and tie it to a GCM registration identifier.
|
void setSupportMessaging(boolean supported)
supported
- whether or not the application supports instant messaging.void setSupportCalling(boolean supported)
supported
- whether or not the application supports calling.void setSupportActiveConnectionInBackground(boolean supported)
SinchClient
.supported
- whether or not the application uses an active connection in
the background.void setSupportPushNotifications(boolean supported)
SinchClient
that this
application is capable of receiving push notifications.supported
- whether or not the application supports push notifications.void setSupportManagedPush(boolean enabled) throws MissingGCMException
enabled
- whether or not managed push is enabledMissingGCMException
- If the device does not have Google Play Services installed.void checkManifest()
start()
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.MissingPermissionException
- if any of the required permissions are
missing.CallClient getCallClient()
CallClient
object for placing and receiving calls.CallClient
object.java.lang.IllegalStateException
- if setSupportCalling(boolean)
is not enabled.@Deprecated MessageClient getMessageClient()
MessageClient
object for sending messages and adding
listeners for message events.MessageClient
object.java.lang.IllegalStateException
- if setSupportMessaging(boolean)
is not enabled.void addSinchClientListener(SinchClientListener sinchClientListener)
SinchClientListener
object handles events from the
SinchClient
such as incoming calls.sinchClientListener
- a SinchClientListener
void removeSinchClientListener(SinchClientListener sinchClientListener)
sinchClientListener
- a SinchClientListener
void start()
startListening
.java.lang.IllegalStateException
- if SinchClient
is already startedMissingPermissionException
- if SinchClient
detects that the app lacks
required
Android permissionsboolean isStarted()
true
if the SinchClient
is started.true
if the SinchClient
is started.@Deprecated void stop()
terminate()
Since version 1.2.0 SinchClient.stop()
does no longer
throw an IllegalStateException if SinchClient
was not started.
This change was made so that any application can call
SinchClient.stop()
on shut down so it is never forgotten.
void terminate()
void terminateGracefully()
void startListeningOnActiveConnection()
void stopListeningOnActiveConnection()
void registerPushNotificationData(byte[] pushNotificationData)
pushNotificationData
- Device specific data that can be used to tie a device to a
specific GCM registration identifier.
The pushNotificationData is what will be passed back in
CallListener.onShouldSendPushNotification(com.sinch.android.rtc.calling.Call, java.util.List<com.sinch.android.rtc.PushPair>)
in
the caller's application, unless the application on the
destination device (the device on which this method is called)
is not running in the background.
java.lang.IllegalStateException
- If the user does not have push capability enabledvoid unregisterPushNotificationData()
@Deprecated void unregisterManagedPush()
ManagedPush.unregisterPushToken()
.SinchClient
is started with managed
push enabled.NotificationResult relayRemotePushNotificationPayload(java.lang.String payload)
SinchClient
if it wasn't already started.payload
- Sinch specific payload which was transferred with the messageNotificationResult relayRemotePushNotificationPayload(android.content.Intent intent)
SinchClient
if it wasn't already started.intent
- Intent received from a GCM receiverSinchHelpers.isSinchPushIntent(Intent)
,
relayRemotePushNotificationPayload(String)
NotificationResult relayRemotePushNotificationPayload(java.util.Map<java.lang.String,java.lang.String> payload)
SinchClient
if it wasn't already started.payload
- Payload received from a FCM RemoteMessage dataSinchHelpers.isSinchPushPayload(java.util.Map)
,
relayRemotePushNotificationPayload(String)
void setPushNotificationDisplayName(java.lang.String displayName)
setSupportManagedPush(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.displayName
- display name may at most be 255 bytes (UTF-8 encoded) long.void setMediaHandover(boolean enable)
enable
- equal to false disables media handover from WiFi to cellular when WiFi is lost.java.lang.String getLocalUserId()
SinchClient
.AudioController getAudioController()
AudioController
object for controlling different audio
settings. You may only call this method while the SinchClient
is
started.AudioController
object for controlling audio settings.java.lang.IllegalStateException
- if SinchClient
isn't started.VideoController getVideoController()
VideoController
object for managing and retrieving views for Video calls.VideoController
object for controlling video settings.Copyright 2016, Sinch AB