-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (48 loc) · 1.86 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const journeyPlayer = xmsdk.XmSdk(); // the Transmit SDK object
const ConnectionSettings = com.ts.mobile.sdk.SDKConnectionSettings; // constractor for sdk connection settings
const XmUIHandler = new xmui.XmUIHandler();
function invokeJourney() {
initSDK((success) => {
console.log(`Transmit SDK init success? ${success}`);
if (!success) return;
const clientContext = getClientContext();
journeyPlayer.authenticate("train1", "authenticate", {}, clientContext)
.then((results) => {
console.log(`Authenticate success: ${results}`)
})
.catch((error) => {
console.error(`Authenticate Error: ${error}`);
})
});
}
function getClientContext() {
return {
uiContainer: document.getElementById("transmitContainer")
};
}
function initSDK(callback) {
const settings = getTransmitConnectionSettings();
journeyPlayer.setConnectionSettings(settings);
journeyPlayer.setUiHandler(XmUIHandler);
// journeyPlayer.setUiAssetsDownloadMode(com.ts.mobile.sdk.UIAssetsDownloadMode.Disable);
journeyPlayer.initialize()
.then((results) => {
console.log(`Transmit SDK initialized succesfuly: ${results}`);
callback(true);
})
.catch((error) => {
// *** see additional info about errors below ⬇⬇⬇
console.error(`Transmit SDK initialization error!: ${error}`);
callback(false);
});
}
function getTransmitConnectionSettings() {
const serverUrl = "https://ps-dev.tsdemo.transmit-field.com";
const appId = "web-training";
const apiTokenId = null;
const apiToken = null;
const realm = "shachar";
let settings = com.ts.mobile.sdk.SDKConnectionSettings.create(serverUrl, appId, apiTokenId, apiToken);
settings.setRealm(realm);
return settings;
}