User consent dialog
By default, Cobrowse will show a user consent dialog when a new session is incoming. You may modify and customize the consent prompt using the SDK.
By default, Cobrowse will show a user consent dialog when a new session is incoming. You may modify and customize the consent prompt as you wish, using the SDK hooks described below.
Admin users may also disable this consent prompt from your account settings if you prefer to remove it entirely: https://cobrowse.io/dashboard/settings
CobrowseIO.confirmSession = function() {
return new Promise(function(resolve, reject) {
// show your UI here
// call resolve(true) to accept the session
resolve(true)
// or reject() to reject the session
})
}-(void) cobrowseHandleSessionRequest:(CBIOSession*) session {
// show your own UI here
// call [session activate: <callback>] to accept and start the session
// provide a callback to handle any errors during session initiation
[session activate: nil];
// or [session end: nil]; to reject the session
}@Override
public void handleSessionRequest(final Activity currentActivity, final Session session) {
// Do something here, e.g. showing a permission request dialog
// Make sure to call activate(<callback>) on the session object if
// you want to start the session.
// Provide a callback if you wish to handle errors during session
// initiation.
session.activate(null);
// or session.end(null) to reject the session
}.NET iOS implementation
.NET iOS implementation
MAUI implementation
You can also achieve this functionality from a cross-platform project. In this case you don't have to implement your own delegate, but instead you subscribe to the SessionDidRequest event:
You can override the default session authorization dialog by adding a handler to the CobrowseIO.Instance.SessionAuthorizing event:
Warning: Callback will be called from non-UI thread, so be sure to dispatch it to the UI one.
To confirm session:
To reject a session:
Example UIs
We've created a set of sample UIs that you may drop directly into your app or website as a starting point to customize the consent prompt.
// A generic consent dialog class
function Consent() {
var container = document.createElement('div');
function content(title, description){
return '\
<div style="background: rgba(50, 50, 50, 0.4); position: fixed; z-index: 2147483647; bottom: 0; top: 0; left: 0; right: 0">\
<div style="color: #333; font-family:sans-serif; line-height:140%; position:fixed; padding:25px; background:white; border-radius:15px; z-index:2147483647; top:50px; left:50%; width:75%; max-width:350px; transform:translateX(-50%); box-shadow:0px 0px 15px #33333322;">\
<div style="text-align:center; margin-top:10px; margin-bottom:20px"><b>'+title+'</b></div>\
<div>'+description+'</div>\
<div style="float:right; margin-top:40px; color:rgb(0, 122, 255);">\
<a class="cobrowse-deny" style="cursor:pointer; padding:10px;">Deny</a>\
<a class="cobrowse-allow" style="cursor:pointer; padding:10px; font-weight: bold;">Allow</a>\
</div>\
</div>\
</div>\
';
}
this.show = function(title, description) {
return new Promise(function(resolve) {
container.innerHTML = content(title, description);
container.querySelector('.cobrowse-allow').addEventListener('click', function(){ resolve(true); this.hide() }.bind(this));
container.querySelector('.cobrowse-deny').addEventListener('click', function(){ resolve(false); this.hide() }.bind(this));
if (document.body) document.body.appendChild(container);
}.bind(this));
}.bind(this);
this.hide = function() {
if (container.parentNode) {
container.parentNode.removeChild(container);
}
}.bind(this);
}
// Integration with Cobrowse
CobrowseIO.confirmSession = function() {
return new Consent().show('Session Request', 'Do you want to share your screen?');
}iOS implementation
Android implementation
MAUI implementation
Subscribe to the SessionDidRequest event in a single place, for example in the MAUI application class:
Last updated
Was this helpful?