The JS bridge and the JS library

The 360dialog SDK provides a JavaScript bridge between an HTML5 based mobile app and our native SDKs for iOS and Android. This offers you the possibility to use the 360dialog SDK from hybrid HTML mobile applications.

There are three components involved with the following roles:

  • js-bridge-min.js: The JavaScript library that exposes the public methods in JavaScript
  • Native JS bridge (referenced as D360SDKJS or sdkjs): A native library that exposes the native SDK methods to js-bridge-min.js
  • The native SDK

All three components have to be integrated using the following steps

Step 1: Integrate the native JS bridge

To integrate the native JS bridge, follow the instructions of your chosen platform:

Step 2: Include the JS library

Both native JS bridges must be used with the JavaScript library.

In your HTML file, include the script:

<script src="https://cdn-js.360dialog.io/d360/1.1.x/js-bridge-min.js"></script>

Step 3: Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<script type="text/javascript">
	
	// Start the SDK
	var options = new D360Options("YOUR APP ID", "YOUR API KEY");
	D360.start(options);

	// Send a custom event with parameters
	var eventParams = {
	    "custom_param_a": 123,
	    "custom_param_b": "xyz",
	    "custom_param_c": true
	};
	D360.events.logCustomEvent("my_custom_event", eventParams);

	// Inform the SDK of a new user id
	D360.users.changeUserID("new user id");

</script>

For more examples, please refer to the JS library reference.

Please note that not all native SDK capabilities are exposed into JavaScript and only the methods documented above are available.