Use 6-digit codes
Cobrowse does not require any visible UI presented to the user but there is the option to present a UI that generates a 6-digit code. Learn more.
By default, Cobrowse does not require any visible UI presented to the user. It will exist in the background of your app, and only activate when agents initiate a new session.
You may optionally present a UI in your app that enables users to generate 6-digit codes. Users may then read a code over the phone or in chat, and agents can use the 6-digit code to initiate the Cobrowse session.
To generate a 6-digit code in your integration you can use the following APIs. Once you have generated the code you can display it to the user in your own UI. You should only generate a code when a user needs it as they expire shortly after creation.
// ensure Cobrowse is loaded
CobrowseIO.client().then(function() {
    // create a code a display it to the user using your own UI
    // ONLY GENERATE CODE WHEN NEEDED. DO NOT GENERATE CODE ON PAGE LOAD.
    CobrowseIO.createSessionCode().then(function(code) {
       console.log('your code is', code);
    });
});Swift
CobrowseIO.instance().createSession { error, session in
    guard error == nil, let code = session?.code()
        else { return }
    
    print(code)
}Objective-C
[CobrowseIO.instance createSession:^(NSError * err, CBIOSession * session) {
    if (err) NSLog(@"Failed to create code")
    else NSLog(@"%@", session.code);
}];CobrowseIO.instance().createSession((err, session) -> {
    if (err != null) Log.w("App", "Failed to create code");
    else if (session != null) Log.i("App", "Session code " + session.code());
});const session = await CobrowseIO.createSession()
console.log('Your 6 digit code is', session.code)Session session = await CobrowseIO.instance.createSession();
log('Your session code: ${session.code}');CobrowseIO.Instance.CreateSession((Exception err, ISession session) => {
    if (err != null) Debug.WriteLine("Failed to create a code");
    else if (session != null) Debug.WriteLine("Session code " + session.Code);
});Session session = await CobrowseIO.Instance.CreateSession();
Console.WriteLine("Code: {0}", session.Code);If you are only using 6 digit codes to start Cobrowse sessions in your implementation, you can prevent the SDK registering in your Cobrowse account until a screen sharing session is required. See the documentation on preventing automatic registration.
Starting and stopping the SDKYou can monitor changes in the state of the session using the Cobrowse delegate methods to listen for events:
Listening for eventsTo see some code samples for how to build a custom UI for your platform see:
6-digit code screenLast updated
Was this helpful?