Listening for events
The Cobrowse SDKs offer a range of events that you can use to hook in to the lifecycle of a Cobrowse session. The lifecycle of a Cobrowse session is based on the following states:
pending - The session has been created, but an agent or device has not yet joined
authorizing - The session is waiting to start, but confirmation from the user is required
active - The screen share session is in progress, frames are streaming
ended - The session is finished and can no longer be used or updated
The typical transition between states of a Cobrowse session is: pending ( -> authorizing) -> active -> ended. If session authorization is disabled (i.e. no user consent is required), the authorizing step will be skipped.

Session Lifecycle Events

You can get insight into the state of the session using the following lifecycle events:

Session Loaded Events

When a Cobrowse session is requested, either by the agent via a push channel, or via a 6 digit code, an event is triggered in the device-side SDKs. The loaded event signifies that a session is initialising, this event is a good opportunity to any one-time setup for the session. To listen to this event:
Web
iOS / MacOS
Android
React Native
1
CobrowseIO.on('session.loaded', session => {
2
console.log('A session was loaded', session)
3
})
Copied!
1
-(void) sessionDidLoad: (CBIOSession*) session {
2
NSLog(@"A session was loaded %@", session);
3
}
Copied!
1
// Must implement CobrowseIO.SessionLoadDelegate
2
@Override
3
public void sessionDidLoad(@NonNull Session session) {
4
Log.i("App", "A session was loaded " + session);
5
}
Copied!
1
CobrowseIO.addListener('session.loaded', session => {
2
console.log('A session was loaded', session)
3
})
Copied!

Session Updated Events

The session updated event is trigged multiple times throughout the life of a session. This signifies that a change to the session configuration has been made, potentially to any of the session properties. For example, the session has been switched into full device mode, or remote control was requested, or a range of other properties. You can tap in to this event to check the new state of the session:
Web
iOS / MacOS
Android
React Native
Xamarin
1
CobrowseIO.on('session.updated', session => {
2
console.log('A session was updated', session)
3
})
Copied!
1
-(void) sessionDidUpdate: (CBIOSession*) session {
2
NSLog(@"A session was updated %@", session);
3
}
Copied!
1
// Must implement CobrowseIO.Delegate
2
@Override
3
public void sessionDidUpdate(@NonNull Session session) {
4
Log.i("App", "A session was updated " + session);
5
}
Copied!
1
CobrowseIO.addListener('session.updated', session => {
2
console.log('A session was updated', session)
3
})
Copied!
1
public void SessionDidUpdate (Session session);
Copied!
In Xamarin.Forms you can subscribe to the following CobrowseIO events:
1
event EventHandler<ISession> SessionDidUpdate;
Copied!

Session Ended Events

The session has been ended and the screenshare has stopped. An ended session cannot be restarted or modified. To listen for the session ended event:
Web
iOS / MacOS
Android
React Native
Xamarin
1
CobrowseIO.on('session.ended', session => {
2
console.log('A session was ended', session)
3
})
Copied!
1
-(void) sessionDidEnd: (CBIOSession*) session {
2
NSLog(@"A session was updated %@", session);
3
}
Copied!
1
// Must implement CobrowseIO.Delegate
2
@Override
3
public void sessionDidEnd(@NonNull Session session) {
4
Log.i("App", "A session was ended " + session);
5
}
Copied!
1
CobrowseIO.addListener('session.ended', session => {
2
console.log('A session was ended', session)
3
})
Copied!
1
public void SessionDidEnd (Session session);
Copied!
In Xamarin.Forms you can subscribe to the following CobrowseIO events:
1
event EventHandler<ISession> SessionDidEnd;
Copied!

Delegate implementation

Our SDKs offer many API touch points for you to customize the behaviour of your integration. These are primarily exposed through the implementation of a delegate object which you then pass to the Cobrowse SDK.
iOS / MacOS
Android
On iOS we offer a protocol you can implement called CobrowseIODelegate. This offers a range of callbacks you can implement such as the lifecycle methods described above, as well as callbacks to control session UIs, consents and redactions.
To assign your delegate implementation, you should use:
1
CobrowseIO.instance.delegate = /* your delegate instance */
Copied!
On Android we offer a range of delegate interfaces that you can implement depending on the functionality you wish to alter.
You can only have one delegate instance configured, so the same instance must be used to implement any of the interfaces that you wish to use from the list here.
CobrowseIO.Delegate - provides callbacks for session lifecycle events
CobrowseIO.SessionLoadDelegate - provides callbacks for session lifecycle events
CobrowseIO.SessionRequestDelegate - for handling session consent requests
CobrowseIO.RemoteControlRequestDelegate - for session remote control consent
CobrowseIO.SessionControlsDelegate - for altering session indicator UIs
CobrowseIO.RedactionDelegate - an option for passing redactions to the SDK
To assign your delegate implementation, you should use:
1
CobrowseIO.instance().setDelegate(/* your delegate implementation */);
Copied!