SinchClient | sinch-rtc
Description: Documentation for sinch-rtc

# Interface SinchClient

SinchClient is an entry point for whole SDK

interface SinchClient {
callClient: CallClient;
localUserId: string;
pushNotificationDisplayName?: string;
addListener(sinchClientListener: SinchClientListener): void;
disableManagedPushSupport(): Promise<void>;
isStarted(): boolean;
relayRemotePushNotification(
payload: Record<string, string>,
): NotificationResult;
removeListener(sinchClientListener: SinchClientListener): void;
setSupportManagedPush(
serviceWorker?: string,
registrationOptions?: RegistrationOptions,
): Promise<void>;
start(): Promise<void>;
terminate(): void;
}

##### Index

### Properties

callClient
localUserId
pushNotificationDisplayName?

### Methods

addListener
disableManagedPushSupport
isStarted
relayRemotePushNotification
removeListener
setSupportManagedPush
start
terminate

## Properties

### callClient

callClient: CallClient

Returns the CallClient object for placing and receiving calls.

#### Returns

the CallClient object.

### localUserId

localUserId: string

Returns the id of the user associated with this SinchClient.

#### Returns

the local user id.

### `Optional`pushNotificationDisplayName

pushNotificationDisplayName?: string

Specify a display name to be used when the Sinch client initiates a call a on behalf of the local user (e.g. for an outgoing video call).

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. display name is also included in an incoming call, Call.remoteUserDisplayName

#### Returns

display name

## Methods

### addListener

- addListener(sinchClientListener: SinchClientListener): void

  The SinchClientListener object handles events from the SinchClient such as incoming calls.

  #### Parameters

  - sinchClientListener: SinchClientListener

    a SinchClientListener

  #### Returns void

### disableManagedPushSupport

- disableManagedPushSupport(): Promise<void>

  Disables the use of managed push.

  #### Returns Promise<void>

  #### See

  SinchClient.setSupportManagedPush

### isStarted

- isStarted(): boolean

  #### Returns boolean

  true if the SinchClient is started.

### relayRemotePushNotification

- relayRemotePushNotification(payload: Record<string, string>): NotificationResult

  Method used to forward the Sinch specific payload extracted from an incoming push notification. This will implicitly start the SinchClient if it wasn't already started.

  #### Parameters

  - payload: Record<string, string>

    Sinch specific payload which was transferred with the message

  #### Returns NotificationResult

  A result indicating initial inspection of the payload.

### removeListener

- removeListener(sinchClientListener: SinchClientListener): void

  Remove listener for client events.

  #### Parameters

  - sinchClientListener: SinchClientListener

    a SinchClientListener

  #### Returns void

### setSupportManagedPush

- setSupportManagedPush(
  serviceWorker?: string,
  registrationOptions?: RegistrationOptions,
  ): Promise<void>

  Enables the use of managed push, where Sinch is responsible for sending your app a push notification when necessary.

  #### Parameters

  - `Optional`serviceWorker: string

    filename of push ServiceWorker definition, default is sw.js

  - `Optional`registrationOptions: RegistrationOptions

    options passed to ServiceWorkerContainer.register(), e.g. `{ scope: '/' }` to control which pages the service worker intercepts. See https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register for full parameter documentation.

  #### Returns Promise<void>

### start

- start(): Promise<void>

  Starts the Sinch client. This must be done prior to making any calls.

  #### Returns Promise<void>

  #### Throws

  InvalidOperationError if SinchClient is already started

### terminate

- terminate(): void

  Terminates the Sinch client, while still leaving it some time to finish up currently pending tasks, for example finishing pending HTTP requests.

  #### Returns void