For the complete documentation index, see llms.txt. This page is also available as Markdown.

Active session controls

Cobrowse active session controls. You can fully customize the interface for a Cobrowse session, including how to end a session.

By default, the Cobrowse SDKs will show a minimal visual indicator to the end-user that a session is active. Our default UI provides an easy way for the end-user to end the session at any time.

You can fully customize the interface for a Cobrowse session, including how to end a session.

The SDK provides hooks for you to render your own interface:

CobrowseIO.showSessionControls = function() {
    // your code, i.e. $('#cobrowse-control').show() or similar
}

CobrowseIO.hideSessionControls = function() {
    // your code, i.e. $('#cobrowse-control').hide() or similar
}

When you override these functions, we will not show any default UI for the end-user to end their session. You can then display your own button or other UI to allow your end-user to end their session.

The SDK provides hooks via CobrowseIODelegate for you to render your own interface:

Swift

func cobrowseShowSessionControls(_ session: CBIOSession) {
    // You can render controls however you like here.
}

func cobrowseHideSessionControls(_ session: CBIOSession) {
    // hide your session controls
}

Objective C

- (void)cobrowseShowSessionControls:(CBIOSession*) session {
    // You can render controls however you like here.
}

- (void)cobrowseHideSessionControls:(CBIOSession*) session {
     // hide your session controls
}

The SDK provides hooks via CobrowseIO.SessionControlsDelegate for you to render your own interface:

Our React Native SDK provides a component you can use to wrap your session control components. Our component will then handle showing and hiding your controls when required:

By default, the native session indicator will still be visible to the user (a red horizontal bar at the top of the application). If you wish to hide this you can set showSessionControls to false:

Listen to these event emitters to override the default session indicator. These methods may be called several times as the session progresses through its lifecycle, so you may need to adjust your UI accordingly.

iOS implementation

The SDK provides hooks via CobrowseIODelegate for you to render your own interface:

Android implementation

You can fully customize the interface for a Cobrowse session. The SDK provides hooks via CobrowseIO.ISessionControlsDelegate for you to render your own interface:

You may override the default session and active display indicator by handling CobrowseIO.Instance.SessionControlsUpdated:

Callback will be called when:

  • Session starts. FrameInfo will contian information about the display currently captured by the screenshare session.

  • Active display is switched. FrameInfo will contain information about the display which is being switched to.

  • Session ends. FrameInfo param will be null. This means that session UI should be hidden.

Warning: Be aware that callback is called from non-UI thread.

Programmatically ending the current session

When implementing your own session controls, it's a good idea to provide the user with some UI to end the current Cobrowse session. You can call the following APIs from your UI to end the session:

if (CobrowseIO.currentSession)
    await CobrowseIO.currentSession.end();
[CobrowseIO.instance.currentSession end:^(NSError * _Nullable err, CBIOSession * _Nullable session) {
    // handle errors here
}];
if (CobrowseIO.instance().currentSession() != null ) {
    CobrowseIO.instance().currentSession().end((err, session) -> {
        // handle errors here
    });
}
// Get a reference to the current session if you don't have one
const session = await CobrowseIO.currentSession();
// if there's an ongoing session, end it
if (session) await session.end()
// Get a reference to the current session if you don't have one
Session? session = await CobrowseIO.instance.currentSession();
// if there's an ongoing session, end it
if (session != null) {
    await session.end()
}
CobrowseIO.Instance().CurrentSession?.End(null);

Example UIs

To illustrate how these APIs should be used we have put together some example code for customizing the active session indicators:

Here's a simple example that re-create the default UI, but with a blue button and some different text:

<script>
CobrowseIO.client().then(function() {
    var button = document.createElement('div');
    button.className = '__cbio_ignored';
    button.textContent = 'End';
    button.style.fontFamily = 'sans-serif';
    button.style.padding = '10px 13px';
    button.style.fontSize = '13px';
    button.style.color = 'white';
    button.style.boxShadow = '0px 2px 5px #33333344';
    button.style.cursor = 'pointer';
    button.style.borderRadius = '30px';
    button.style.background = 'blue';
    button.style.position = 'fixed';
    button.style.zIndex = '2147483647';
    button.style.bottom = '20px';
    button.style.left = '50%';
    button.style.transform = 'translateX(-50%)';
    button.addEventListener('click', function() {
        if (CobrowseIO.currentSession) CobrowseIO.currentSession.end();
    });

    CobrowseIO.showSessionControls = function() {
        document.body.appendChild(button);
    }

    CobrowseIO.hideSessionControls = function() {
        if (button.parentNode) button.parentNode.removeChild(button);
    }
});
</script>

iOS implementation

Android implementation

You can fully customize the interface for a Cobrowse session. The SDK provides hooks via CobrowseIO.ISessionControlsDelegate for you to render your own interface:

MAUI implementation

First, create an indicator view using MAUI (CobrowseCustomView.xaml):

Then, in the iOS-specific files:

And in the Android-specific files:

Make sure the delegates you just created are passed into the Cobrowse.io SDK after the SDK is started:

Last updated