Quickstart

The Layers of SDK:

Business layer consists of the high level APIs, which are the direct mappings to user requirements. The most commonly used components allow the clients to include the components as objects which can then be called to perform the tasks.

Communication layer is also known as the “service layer”. This layer handles the client-server communication protocols.

M800 Web SDK Components

SDK Component
Description

Account

Manages the sign up and user accounts services

Call

Manages the call features of the M800 Web SDK

Connection

Manages the connection to M800 server

Contact

Manages the contacts in the application

Core

Manages the clients and its services in the application

File

Manages the file services available in the SDK

IM

Manages the chat and messaging features in the SDK

Media

Manages the different types of media and its services available in the SDK

Verification

Manages the different types of verification supported by the SDK

Configure M800 Web SDK Client

Client

  • Entry point in the M800 Web SDK
  • Referred to as the M800Core.Client
    Uses:
         1. To configure the capabilities of the user and device
         2. To provide access to feature modules
    

The Client can be configured into 2 sets of values:

1. Application metadata 
2. Configurations

Both values come in object form.

This section provides guidelines on how to configure the M800 Client in your application. This is the primary integration point of the M800 Web SDK into your application.

Use M800 server

Initialize M800Core.Client object with your application metadata and configurations

const { Client } = M800Core;
 
const appMeta = {
    carrier: '<carrier>',
    applicationIdentifier: '<applicationIdentifier>',
    applicationKey: '<applicationKey>',
    applicationSecret: '<applicationSecret>',
    developerKey: '<developerKey>',
    applicationVersion: '<applicationVersion>',
};
 
const config = {
    imServers: [ 'imServerUrl' ],
    signUpServers: [ 'signUpServerUrl' ],
    verificationServers: [ 'verificationServerUrl' ],
    callServers: [ 'callServerUrl' ],
 
    //additional configurations
};
 
const client = new Client (appMeta, config);

There are also some additional configurations which the application may use and customize. These configurations, refer to the parameters that may control the application behavior and come with default values if not identified.

Wait for Core Modules to be Ready

Initializing the M800 Web SDK Client ensures that the client is ready to be used by the application. It is important that at some point of the M800 Web SDK Client initialization process, the status can be monitored to know if the core modules are ready to use. The READY event will be emitted after all the core modules are initialized.

Listen to the READY event:

const { Client } = M800Core;
const { READY } = M800Core.ClientEvent;
 
const client = new Client (appMeta, config);
client.on(READY, () => {
    // M800 Web SDK core modules are ready to use
})

Add Features to the M800 Web SDK

The Client allows adding of M800 Web SDK compatible features dynamically via its addFeature( ) method.

client.addFeature(bundle, overrides);

The bundle should be a M800 Web SDK compatible bundle which has ‘name’ and ‘getModuleDefinitions’ properties.

name - name of the feature

getModuleDefinitions - return the feature's module definitions to initialize.

A module or a feature definition includes:

  • the name of the feature
  • the deps which is an array of string enlisting the feature dependencies
  • a function factory which creates an instance of the corresponding service.

When overrides parameter is specified, the function will override the modules defined in the bundle, with the new feature definition.

const overrides = {
        call: {
             deps: [ /* dependencies */ ],
             factory: (...deps) => {
             // Could add other input based on specific needs return new MyCustomCallManager(...deps);
 
             },
        }
}

Once all the feature modules are initialized, the FEATURE_READY event will be emitted with the feature name.

client.on(FEATURE_READY, (feature) => {
      if (feature === 'featureName') {
      // the feature is ready to use
      }
});

Override Client Initialization Strategies

The M800 Web SDK Client is pre-loaded with a default set of dependencies and services for its application modules. Customize these values to tune the Client to specific use cases and scenarios in their application.

The M800 Web SDK Client allows the flexibility of customizing its application modules by overriding the default values using the overrides parameter. The parameter values should be provided in the client configuration files of the application.

The application can initialize the Client with overrides parameter:

const overrides = {
       'service.connect': {
             deps: [],
             factory: () => new CustomConnectService(),
 
       },
       media: {
             deps: ['service.notification'],
             factory: (notificationService) =>
                   new CustomMediaManager(notificationService),
       },
};
 
const client = new Client (appMeta, configs, overrides);

Load Feature Modules Asynchronously

To add a call feature asynchronously:

const { Client } = M800Core;
const { FEATURE_READY } = M800Core.ClientEvent;
 
const client = new Client(appMeta, config);
 
// load M800 WebSDK bundle into the page
// the module will be available as a global object
 
const callBundleScript = document.createElement('script');
callBundleScript.src = 'lib/M800Call.js';
document.body.appendChild(callBundleScript);
 
callBundleScript.addEventListener('load', () => {
     client.addFeature(M800Call);
});
 
client.on(FEATURE_READY, (feature) => {
     if (feature === 'call') {
         // call feature is ready to use
     }
});

Quickstart


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.