Main webex.Application object. You use this object to obtain information about the application and its context, specify URLs for sharing, and register event listeners.

Example

const app = new window.webex.Application();
await app.onReady();
//Access any of the app properties / events / methods below

Remarks

Available since 1.1.0

Hierarchy

  • Application

Implements

  • IApplication

Properties

application: WebexAppsApplication = ...

Object that holds state information about an embedded app and other actions

This is an instance of WebexAppsApplication

context: IContext = ...

This context object can provide you with contextual information such as information about one of the following,

log: ILog = ...

Instance that has information about a log class's state and other log related actions

This is an instance of ILog

meeting: WebexAppsMeeting = ...

Object that holds state information about a meeting and other meeting actions

This is an instance of WebexAppsMeeting

space: WebexAppsSpace = ...

Instance that has information about a space's state and other space related actions

This is an instance of WebexAppsSpace

Events

application:displayContextChanged: string

Fired when the rendering context of the application changes, for example, when a user pops out the app from the sidebar to a new window. Event object contains the app's new display context.

Possible values for meeting-based apps are one of,

  • MEETING_SIDEBAR

  • MEETING_STANDALONE_WINDOW

  • MEETING_MAINVIEW (for meeting-based apps)

Possible values for meeting-based apps are one of,

  • "SPACE_TAB" (for messaging-based apps).

Note - This event is currently not emitted by messaging-based apps

Remarks

Available since 1.1.0

Example

app.onReady().then(() =>  {
app.listen()
.then(() => {
app.on("application:displayContextChanged", (event) => {
console.log("Display context changed. New display context:", event);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});
application:shareStateChanged: boolean

Fired when an Open Together session is started or ended by the user. The event object is a boolean that's set to true if an Open Together session has just started, or false if a session has just ended.

Remarks

Available since 1.1.0

Example

const app = new webex.Application();
app.onReady().then(() => {
app.listen()
.then(() => {
app.on("application:shareStateChanged", (event) => {
console.log("Share state changed. Sharing state is:", event);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});
application:themeChanged: string

Fired when the user selects a new application theme. The event object is a string indicating the newly selected theme.

Possible values are LIGHT and DARK.

Remarks

Available since 1.1.0

Example

app.onReady().then(() =>  {
app.listen()
.then(() => {
app.on("application:themeChanged", (event) => {
console.log("Theme changed. New theme:", event);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});
application:viewStateChanged: string

This event is fired when the application view changes.

Possible values are IN_FOCUS and OUT_OF_FOCUS.

Remarks

Available since 2.0.0

Example

app.onReady().then(() =>  {
app.listen()
.then(() => {
app.on("application:viewStateChanged", (viewState) => {
console.log("View State Changed. Current state:", viewState);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});

Accessors

  • get about(): null | string
  • Contains general information about the client app (Webex or Meeting Center) in which the app is running. This format is subject to change and should only be used for diagnostic purposes.

    Remarks

    Available since 1.1.0

    Returns null | string

  • get capabilities(): null | string[]
  • Indicates the capabilities of the device on which the embedded app is running.

    Can be combination of the following: "TOUCH", "SHARED_SYSTEM", "MULTIPLE_USER_SYSTEM", and "VIEW_ONLY".

    Currently not in use and subject to change. An empty string array is currently returned.

    Remarks

    Available since 1.1.0

    Returns null | string[]

  • get deviceType(): null | string
  • The given device form factor. One of the following:

    • "DESKTOP" - Desktop client

    • "MOBILE" - Mobile device client (iPhone or Android device, for example)

    • "BROWSER" - Web browser client

    • "ROOM_SYSTEM_PERSONAL" - Webex Device running in personal mode

    • "ROOM_SYSTEM_SHARED" - Webex Device running in shared mode (currently not supported)

    Remarks

    Available since 1.1.0

    Returns null | string

  • get displayContext(): null | string
  • Display context in which the embedded app is running.

    Can be one of the following strings "MEETING_SIDEBAR", "MEETING_STANDALONE_WINDOW", "MEETING_MAINVIEW", or "SPACE_TAB".

    The default is "MEETING_SIDEBAR" for meeting-based apps and "SPACE_TAB" for messaging-based apps.

    Remarks

    Available since 1.1.0

    Returns null | string

  • get embeddedSdkVersion(): null | string
  • Indicates the actual version of the SDK embedded in the client following semantic versioning rules. The webex.Application.sdkVersion property provides the maximum SDK version that the client implements.

    Remarks

    Available since 1.1.0

    Returns null | string

  • get isPrivateDataAvailable(): null | boolean
  • Indicates if the app has access to personally identifiable information for the current user, meeting, or space (true), or if those values are empty or derived (false).

    See Personally Identifiable Information (PII) and Embedded Apps for more information about derived PII values.

    Remarks

    Available since 1.1.0

    Returns null | boolean

  • get isShared(): null | boolean
  • Indicates if the URL specified with a previous call to setShareUrl() has been shared in a meeting or space by the user clicking Open Together or Add to Tab. A value of TRUE indicates the URL has been shared; FALSE indicates the URL has not been shared.

    Example

    The following example checks if a sharing session is in progress before calling `setShareUrl()`. ```javascript function handleSetShare(url) if (app.isShared) { console.log('ERROR: setShareUrl() should not be called while session is active'); return; } // Call setShareUrl() as usual... } ```

    Remarks

    Available since 1.1.0

    Returns null | boolean

  • get language(): null | string
  • Contains the ISO-639 language code of the language being used by the client (for example, "en-US", "da-DK", etc.).

    Remarks

    Available since 1.1.0

    Returns null | string

  • get sdkVersion(): null | string
  • Indicates the maximum SDK version that the client (Meeting Center or Webex app, for example) implements, following semantic versioning rules. For example, a value of "1.1.0" might be returned for Meeting Center client versions 41.6-41.9. The webex.Application.embeddedSdkVersion property contains the actual version of the SDK embedded in the client.

    Remarks

    Available since 1.1.0

    Returns null | string

  • get theme(): null | string
  • Indicates the color theme that the user has selected for Webex or Meeting Center. Possible values are Theme.LIGHT or Theme.DARK.

    Remarks

    Available since 1.1.0

    Returns null | string

Methods

  • Clears the URL previously set using setShareUrl() and removes the Open Together or Add to Tab button.

    Remarks

    Available since 1.1.0

    Example

    const app = new webex.Application();
    await app.onReady();
    app.clearShareUrl()

    Returns Promise<any>

  • Initiates a single sign-on (SSO) authentication flow with a third-party identity provider in the system web browser at the specified URL. Returns a promise containing an OAuth authorization code from the ID provider, or a error code number.

    WARNING initiateSystemBrowserOAuth is not supported in Webex for Government (FedRAMP).

    In addition to any OAuth parameters required by the ID provider, the specified URL's redirect_uri query parameter must be set to https://oauth-helper-prod.wbx2.com/helperservice/v1/callback.

    This callback correlates the authorization code returned by the identity provider with the embedded app that initiated the OAuth flow, and communicates that information back to your embedded app.

    Notes:

    The Valid domains configuration option for your embedded app must include the domain for the SSO page URL you pass to initiateSystemBrowserOAuth() (accounts.example.com, for example).

    Returns

    {Promise.<string | number>} - Authorization code that the embedded app can exchange for an ID or access token from the SSO provider.

    Example

    // Variable to save authorization code
    let authCode;
    // Initiate SSO flow
    app.initiateSystemBrowserOAuth("https://accounts.example.com/auth?client_id=...&redirect_uri=https://oauth-helper-prod.wbx2.com/helperservice/v1/callback")
    .then(function (response) {
    // Get authorization code from JSON response
    console.log("initiateSystemBrowserOAuth() succeeded")
    authCode = response;
    // Exchange authorization code for a token with the SSO provider. This part of the OAuth flow
    // is the responsibility of the embedded app, e.g.
    exchangeCodeForToken(authCode);
    })
    .catch(function (reason) {
    console.error("initiateSystemBrowserOAuth() failed with reason=",
    window.webex.Application.ErrorCodes[errorcode]
    );
    }

    Remarks

    Available since 1.5.0

    Parameters

    • authenticateUrl: string

      Parameterized URL that's opened in the system web browser to initiate the SSO process. The URL's redirect_uri parameter must be set to https://oauth-helper-prod.wbx2.com/helperservice/v1/callback. (Max length: 2083 characters).

    Returns Promise<any>

  • Helper function that returns true if the client (Webex or Meeting Center app) supports a given version of the embedded apps SDK. The framework supports major.minor and major.minor.patch versioning. For example, "1.4" and "1.4.1" are valid version string formats, but "1" or "1.4.5.1" are not.

    Also note that "1.4" is identical to "1.4.0".

    Returns

    {boolean}

    Remarks

    Available since 1.5.0

    Example

    The following checks if the Webex or Meeting Center app supports the "1.5.0" SDK version to determine if it can call the app.initiateSystemBrowserOAuth() method. ```javascript if(app.isSdkSupported("1.5.0")) { // Client supports initiateSystemBrowserOAuth() method, initiate SSO flow: app.initiateSystemBrowserOAuth("https://...") } ```

    Parameters

    • version: string

      SDK version required by the API.

    Returns boolean

  • Used to register an event listener for a specified event. Either returns a successful Promise indicating that your app is ready to listen for events, or a failed promise indicating an error occurred. The listener must be registered after the app.onReady() promise has successfully completed.

    Example

    app.onReady().then(() => {
    log('onReady()', { message: 'host app is ready' })
    app.listen().then(() => {
    app.on('space:infoChanged', (payload) => log('space:infoChanged', payload));
    })
    });

    Returns

    {Promise.<void>}

    Remarks

    Available since 1.1.0

    Returns Promise<any>

  • Stops listening for the specified event.

    Remarks

    Available since 1.1.0

    Parameters

    • eventName: string

      Name of the event to stop listening to.

    • callback: (() => void)
        • (): void
        • Returns void

    Returns number

  • Registers a listener function to be called when the specified event is raised. Your app must first call app.listen() before registering listeners for specific events.

    Remarks

    Available since 1.1.0

    Example

    The following registers a listener for the `space:infoChanged` event that logs the Space object it receives as an event object to the console. ```javascript var app = new window.webex.Application(); app.onReady().then(() => { log('onReady()', { message: 'host app is ready' }) app.listen().then(() => { app.on('space:infoChanged', (payload) => log('Space info:', payload)); }) }); ```

    Parameters

    • eventName: string

      One of the supported events.

    • callback: ((eventObj: object) => void)

      Function called when a given event is raised. Callback function will be passed the an event object containing details about the event.

        • (eventObj: object): void
        • Parameters

          • eventObj: object

          Returns void

    Returns number

  • Called when the webex.Application object has been initialized and the SDK is ready for use by your app.

    Returns

    {Promise.<void>}

    Remarks

    Available since 1.1.0

    Example

    The following example waits for `onReady()` before logging the main webex.Application object to the JavaScript console. ```javascript var app = new window.webex.Application();

    app.onReady().then(function () { console.log('App is ready. App info:', app); }); ```

    Returns Promise<any>

  • Opens an HTTPS or custom protocol URL in the default system browser. The specified URL must use https: or a custom protocol, such as webexteams: (to open the Webex app) or mailto: (to open the default mail app).

    HTTPS URLs are validated against the list of allowed domains specified by the embedded app's configuration options. If a URL's domain doesn't match one of the app's allowed domains, or if it uses the http: protocol, then the call fails and an ACCESS_DENIED error is returned.

    For URLs that specify custom protocols, the user is presented with a dialog asking them to allow or deny the request to open the app associated with the specified protocol. If the user clicks Open external link then Webex opens the associated app. Users can optionally save their preference to always open the associated app. User preferences are stored in local storage. If the user clicks Cancel then the call fails and an ACCESS_DENIED error is returned.

    Returns

    {Promise.<void>}

    Remarks

    Available since 1.4.0

    Example

    The following custom function passes a Webex teams space URL ("webexteams:") to `openUrlInSystemBrowser()`. If an error occurs the error message is displayed in the JavaScript console. ```javascript function openTeamSpace() { app.openUrlInSystemBrowser("webexteams://im?space=87a7b58d-bad1-4e2f-83c9-91aeb21c65f6").catch((errorcode) => { console.log("Error: ", window.webex.Application.ErrorCodes[errorcode]); }) } ```

    Example

    The following custom function opens an `https` URL. The URL's domain must match one of the embedded app's allowed domains. If an error occurs the error message is displayed in the JavaScript console. ```javascript function openSignInPage() { app.openUrlInSystemBrowser("https://www.example.com/signin").catch((errorcode) => { console.log("Error: ", window.webex.Application.ErrorCodes[errorcode]); }) } ```

    Parameters

    • url: string

      The URL to open in the system's default browser.

    Returns Promise<any>

  • Sets the URL to share in a meeting or space. Calling this method in a meeting causes the Open Together button to appear. In a space, calling this method causes the Add to Tab button to appear.

    Returns

    {Promise} One of the following static ErrorCodes.

    0 = SUCCESS, 1 = GENERIC_ERROR, 2 = INVALID_ARGUMENT

    Remarks

    Available since 1.1.0

    Example

    The following provides values for all three parameters to `setShareUrl()`. ```javascript const app = new webex.Application(); await app.onReady(); app.setShareUrl( "https://www.example.com/app_internal/", "https://www.example.com/app_external/", "Application name" ) ```

    Example

    The following demonstrates how to call `setShareUrl()` for a messaging space when you don't want users to open your app outside of Webex or Meeting Center. ```javascript const app = new webex.Application(); await app.onReady(); app.setShareUrl( "https://www.example.com/app_internal/", "", "Application name" ) ```

    Parameters

    • internalUrl: string

      Required. URL to share with meeting participants, or add as a tab to a space. The application at the specified URL must integrate with the embedded app framework. (Maxiumum length: 2083 characters)

    • externalUrl: string

      Optional. URL of a version of the application for viewing outside of Webex or Meeting Center (i.e. in a standard web browser). This URL is used in a messaging space when a user selects Open in Browser or Copy URL from your app's space tab menu. Pass an empty string ("") for this parameter if you don't want users to open an external version of your app from a messaging space. This value is currently not used by in-meeting apps. (Max length: 2083 characters).

    • title: string

      Required. Title of the application window for an in-meeting app, or of the tab for an in-space app. (Max length 256 characters.)

    • optional: object = {}

    Returns Promise<any>

  • Removes all event listeners registered by your application.

    Remarks

    Available since 1.1.0

    Returns void