Skip to content

ANDROID Javascript bridge to Contextual SDK

This document focuses on HTML Tip/Modals that allows the user to include their own HTML, CSS and Javascript source code. Contextual SDK supports JSBridge meaning by coding javascipt in the Contextual Dashboard it can call functions in our Contextual SDK native code.

Quick Example Code for you to try out

HTML

1
2
3
4
5
<h1>The onclick Event</h1>
<p>The onclick event is used to trigger a function when an element is clicked on.</p>
<p>Click the button to trigger a function that will output "Hello World" in a p element with id="demo".</p>
<p><input id="button" name="button" type="submit" value="Go to Next Tip" /></p>
<p id="demo"></p>

Javascript

1
2
3
document.getElementById('button').onclick = function() {
   var sum = window.contextual.switchToNextTip();
};

Dashboard

You can then input the HTML and Javascript here:

Contextual JS Bridge

JSBridge methods to Handle clicks inside HTML:

switchToNextTip

Shows the NEXT Tip/Modal if there is any and send "next" input to the Contextual Dashboard analytics for you to view later.

1
   var sum = window.contextual.switchToNextTip();

switchToPreviousTip

Show the PREVIOUS Tip/Modal if there is any and send "back" input to the Contextual Dashboard analytics for you to view later.

1
   var sum = window.contextual.switchToPreviousTip();

dismiss

Closes the Tip/Modal and sends "dismiss" input to the Contextual Dashboard analytics to for you to view later.

1
   var sum = window.contextual.dismissTip();


Last update: 2024-01-16