<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url(./assets/Athenas.jpeg);
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body background-image="./assets/Athenas.jpeg">
<!-- // Pericles -->
<script src="https://cdn.cai.tools.sap/webchat/webchat.js" channelId="<channelId>" token="<token>" id="<id>"> </script>
<meta name="viewport" content="width=device-width">
</body>
</html>
{
"type": "object",
"BindType": "",
"properties": {
"url": {
"type": "string",
"BindType": ""
}
}
}
import * as app from 'tns-core-modules/application';
import { IControl } from 'mdk-core/controls/IControl';
import { BaseObservable } from 'mdk-core/observables/BaseObservable';
export class chatClientClass extends IControl {
private _observable: BaseObservable;
private _webView: any;
private _url: string;
public initialize(props: any): any {
super.initialize(props);
if (this.definition().data.ExtensionProperties.url) {
this._url = this.definition().data.ExtensionProperties.url;
} else {
this._url = "file:///android_asset/webchat.html";
}
if (app.android) {
this._webView = new android.webkit.WebView(this.androidContext());
this._webView.getSettings().setJavaScriptEnabled(true);
this._webView.getSettings().setAllowFileAccessFromFileURLs(true);
this._webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
this._webView.getSettings().setAllowFileAccess(true);
this._webView.getSettings().setAllowContentAccess(true);
this._webView.loadUrl(this._url);
app.android.on(app.AndroidApplication.activityPausedEvent, this.onActivityPaused, this);
app.android.on(app.AndroidApplication.activityResumedEvent, this.onActivityResumed, this);
app.android.on(app.AndroidApplication.saveActivityStateEvent, this.onActivitySaveInstanceState, this);
app.android.on(app.AndroidApplication.activityDestroyedEvent, this.onActivityDestroyed, this);
var that = this;
}
}
private onActivityPaused(args) {
console.log("onActivityPaused()");
if (!this._webView || this != args.activity) return;
this._webView.onPause();
}
private onActivityResumed(args) {
console.log("onActivityResumed()");
if (!this._webView || this != args.activity) return;
this._webView.onResume();
}
private onActivitySaveInstanceState(args) {
console.log("onActivitySaveInstanceState()");
if (!this._webView || this != args.activity) return;
this._webView.onSaveInstanceState(args.bundle);
}
private onActivityDestroyed(args) {
console.log("onActivityDestroyed()");
if (!this._webView || this != args.activity) return;
this._webView.onDestroy();
}
public view() {
if (app.android) {
return this._webView;
}
}
public viewIsNative() {
return true;
}
public observable() {
if (!this._observable) {
this._observable = new BaseObservable(this, this.definition(), this.page());
}
return this._observable;
}
public setContainer(container: IControl) {
// do nothing
}
public setValue(value: any, notify: boolean, isTextValue?: boolean): Promise<any> {
// do nothing
return Promise.resolve();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
14 | |
11 | |
9 | |
8 | |
8 | |
7 | |
6 | |
6 | |
6 |