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 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 before 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.
        Throws:
        MissingPermissionException - if any of the required permissions are missing.
      • getCallClient

        CallClient getCallClient()
        Returns the CallClient object for placing and receiving calls.
        Returns:
        the CallClient object.
        Throws:
        java.lang.IllegalStateException - if disposed.
      • removeSinchClientListener

        void removeSinchClientListener​(SinchClientListener sinchClientListener)
        Remove listener for client events.
        Parameters:
        sinchClientListener - a SinchClientListener
      • start

        void start()
        Starts the Sinch client. This must be done prior to making any calls or calling startListening.
        Throws:
        java.lang.IllegalStateException - if SinchClient is already started
        MissingPermissionException - if SinchClient detects that the app lacks required Android permissions
      • isStarted

        boolean isStarted()
        Returns true if the SinchClient is started.
        Returns:
        true if the SinchClient 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 the SinchClient 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 the SinchClient 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 the SinchClient 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 using 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.
        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 this SinchClient.
        Returns:
        the local user id.
      • getAudioController

        AudioController getAudioController()
        Returns an AudioController object for controlling different audio settings. You may only call this method while the SinchClient is started.
        Returns:
        an AudioController object for controlling audio settings.
        Throws:
        java.lang.IllegalStateException - if SinchClient isn't started.
      • getVideoController

        VideoController getVideoController()
        Returns a VideoController object for managing and retrieving views for Video calls.
        Returns:
        an VideoController object for controlling video settings.