0% found this document useful (0 votes)
31 views

JS SDK

fff

Uploaded by

Miguel Angel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

JS SDK

fff

Uploaded by

Miguel Angel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

©2023 GeoComply Solutions Inc. All rights reserved.

Table of contents
Table of contents 1
Introduction 2
Quick Guides 2
Step 1: Include SDK and Initialize GLV Client 2
Step 2: Verify Location ( geolocate/setupAndGeolocate ) 3
1. geolocateOptions 3
2. middleCallback 4
3. finalCallback 7
Example 8
UI Suggestion 9
That’s It! 10

©2023 GeoComply Solutions Inc. All rights reserved.


1
Introduction
GeoComply team introduces a New Version for GLV JS SDK to resolve user experience
challenges and simplify the journey and verification process.

Quick Guides
For the clients who are integrated with JS SDK 3.3 or lower, stop using the request()
method and follow the steps below to integrate with JS SDK 4.0

● If you use the method: client.request(); from the previous version of JS SDK,
remove or comment on it.
// client.request();
● Remove all related hint event listeners. They are redundant now.
// client.on(‘all_events’, callback);

Step 1: Include SDK and Initialize GLV Client

There are two ways:


● Using <script> tag:
<script
src="https://cdn.geocomply.com/{CLIENT_ID}/glv.js"
type="text/javascript">
</script>
<script type="text/javascript">
// Initialize new GLV Client
var client = GCOobee.createClient();
</script>

IMPORTANT: It is mandatory to use our CDN link instead of making


a copy on your own CDN.

● Using AMD / RequireJS:

define(['gc-oobee'], function(GCOobee) {
// Initialize new GLV Client
var client = GCOobee.createClient();

©2023 GeoComply Solutions Inc. All rights reserved.


2
});

Step 2: Verify Location ( geolocate/setupAndGeolocate )

● If users have not installed the GLV app yet, you should use the setupAndGeolocate
method. It will navigate to the store, and after installing the app successfully and going
back to browser, the verify location process will automatically start.

● Otherwise, If users already have installed the GLV app then just use the geolocate
method to perform the location verification.

GLV (Geoguard Location Validator) is a mobile application. It is a necessary


part of the whole GLV System. You need to install it on your device to use GLV
solution. (Appstore / Playstore)

client.geolocate(geolocateOptions, middleCallback, fincalCallback);


(1) (2) (3)
client.setupAndGeolocate(geolocateOptions, middleCallback, fincalCallback);

1. geolocateOptions

Put all necessary input data inside geolocateOptions Object on every geolocation
request

var geolocateOptions = {

oobeeUrl: 'URL of GLV Server 2.x',

license: 'license_string',

userId: 'user_id_123',

reason: 'login' || 'betting'

};

©2023 GeoComply Solutions Inc. All rights reserved.


3
The new oobeeURL should be requested from your account manager.

2. middleCallback

The middle callback should act like the middleware action needed to complete the
process, like requiring users to open/install GLV App or grant some permissions…
Sometimes it will return the log message to inform the process’s status.

var middleCallback = function (data) {


switch (data.type) {
case 'LOG':
console.log(data.message);
break;
case 'INTERACTION':
handleInteraction(data);
break;
default:
console.log(`Unhandled ${JSON.stringify(data)}`);
}
}

// Example of data object


data = {
type: 'INTERACTION',
message: 'Please install or open the GLV and grant all needed
permissions to geolocate',
reason: 'app_required',
yes: function() {}, // continue
no: function () {} // abort
}

// Example of handleInteraction
// Using Sweet alert lib to generate Popup

©2023 GeoComply Solutions Inc. All rights reserved.


4
JavaScript
var handleInteraction = function (data) {
Swal.fire({
title: 'INTERACTION REQUIRED',
html: data.message,
showConfirmButton: true,
showCancelButton: true,
cancelButtonColor: '#d33',
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK',
cancelButtonText: 'Skip',
}).then(function (result) {
if (result.value) {
data.yes();
} else {
data.no();
}
});
};

The handleInteraction method should show the POPUP to ask the help from users by
tapping on the button to continue the process.

©2023 GeoComply Solutions Inc. All rights reserved.


5
● We suggest that the POPUP should show the message and buttons below

● If you want to provide an escape way to users can cancel the process, try this one:

©2023 GeoComply Solutions Inc. All rights reserved.


6
There is a reason field inside the INTERACTION data object for you
can detect if you want to use your message as below:

● app_required
○ when need to open the app to geolocate.
● tlb_require
○ when need to open TLB (TrueLocation Browser) to geolocate.
● location_required
○ when Location permission is not granted.
● precise_location_required
○ when Precise Location permission is not granted.
● notification_required
○ when Notification on iOS permission is not granted. (Android no need
notification permission anymore)
● app_update_required
○ when app is out of date, need to update.

3. finalCallback

The final callback will receive the result or error of geolocate request.

const finalCallback = function (err, data) {


if (err) {
var code = err.error_code;
var message = err.error_message;
console.log('Geolocate failed with: ' + code);
console.log('Geolocate failed with: ' + message);
} else {
console.log('Geolocate succeeded with data: ' + data);
}
};

©2023 GeoComply Solutions Inc. All rights reserved.


7
Example
// Initialize new GLV Client
var client = GCOobee.createClient();

const middleCallback = function (data) {


switch (data.type) {
case 'LOG':
console.log(data.message);
break;
case 'INTERACTION':
handleInteraction(data);
break;
default:
console.log(`Unhandled ${data.type}: ${data.message}`);
}
};
const finalCallback = function (err, data) {
if (err) {
var code = err.error_code;
var message = err.error_message;
console.log('Geolocate failed with: ' + code);
console.log('Geolocate failed with: ' + message);
} else {
console.log('Geolocate succeeded with data: ' + data);
}
};

var geolocateOptions = {
oobeeUrl: 'oobee_url,
license: 'license_string',
userId: 'user1',
reason: 'login',
…optionalParameters
}

client.geolocate(geolocateOptions, middleCallback, finalCallback);


// or
client.setupAndGeolocate(geolocateOptions, middleCallback, finalCallback);

©2023 GeoComply Solutions Inc. All rights reserved.


8
UI Suggestion
Whenever you want to verify location (aka perform geolocate), you should ask for the
action from users by clicking a button instead of invoking silently in the background

● If you want to verify location right after login success try this

● If you want to verify location when users perform betting

©2023 GeoComply Solutions Inc. All rights reserved.


9
Sometimes, you will receive some errors as below
● 96: Could not find a transaction with id,
● 99: Internal Server,
● 100: Unexpected
● 113: The connection to local server was lost
● 114: User cancel register/geolocate process
● 600: Unexpected error occurred
Please try again one more time.

That’s It!
Please check the GeoGuard Location Validator JS SDK, Interface Definition v4.0, for more
detailed information. Thank you.

©2023 GeoComply Solutions Inc. All rights reserved.


10

You might also like