rn-erxes-sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/App.js +59 -0
- package/lib/commonjs/App.js.map +1 -0
- package/lib/commonjs/index.html +1 -1
- package/lib/commonjs/index.js +7 -54
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/App.js +51 -0
- package/lib/module/App.js.map +1 -0
- package/lib/module/index.html +1 -1
- package/lib/module/index.js +1 -52
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/App.d.ts +7 -0
- package/lib/typescript/App.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +52 -0
- package/src/index.html +1 -1
- package/src/index.tsx +1 -59
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNativeWebview = require("react-native-webview");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const ErxesSDK = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
script
|
|
14
|
+
} = _ref;
|
|
15
|
+
const onMessage = data => {
|
|
16
|
+
const {
|
|
17
|
+
notificationCount
|
|
18
|
+
} = JSON.parse(data.nativeEvent.data);
|
|
19
|
+
console.log('****************** ', notificationCount);
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
22
|
+
ref: () => {},
|
|
23
|
+
source: _reactNative.Platform.OS === 'ios' ? require('./index.html') : {
|
|
24
|
+
uri: 'file:///android_asset/index.html'
|
|
25
|
+
},
|
|
26
|
+
originWhitelist: ['*'],
|
|
27
|
+
sharedCookiesEnabled: true,
|
|
28
|
+
cacheEnabled: true,
|
|
29
|
+
allowFileAccess: true,
|
|
30
|
+
domStorageEnabled: true,
|
|
31
|
+
thirdPartyCookiesEnabled: true
|
|
32
|
+
// allowingReadAccessToURL
|
|
33
|
+
// style={{ width: 200 }}
|
|
34
|
+
,
|
|
35
|
+
onLoadEnd: syntheticEvent => {
|
|
36
|
+
// update component to be aware of loading status
|
|
37
|
+
const {
|
|
38
|
+
nativeEvent
|
|
39
|
+
} = syntheticEvent;
|
|
40
|
+
console.log(nativeEvent.loading);
|
|
41
|
+
},
|
|
42
|
+
javaScriptEnabled: true,
|
|
43
|
+
onError: er => {
|
|
44
|
+
console.log(er);
|
|
45
|
+
},
|
|
46
|
+
startInLoadingState: true
|
|
47
|
+
// renderLoading={() => <Loader />}
|
|
48
|
+
,
|
|
49
|
+
injectedJavaScript: script
|
|
50
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
51
|
+
|
|
52
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
53
|
+
,
|
|
54
|
+
onMessage: onMessage
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var _default = ErxesSDK;
|
|
58
|
+
exports.default = _default;
|
|
59
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNativeWebview","_reactNative","obj","__esModule","default","ErxesSDK","_ref","script","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","WebView","ref","source","Platform","OS","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript","_default","exports"],"sourceRoot":"../../src","sources":["App.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAMxC,MAAMG,QAA6B,GAAGC,IAAA,IAAgB;EAAA,IAAf;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAC/C,MAAME,SAAS,GAAIC,IAAS,IAAK;IAC/B,MAAM;MAAEC;IAAkB,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,WAAW,CAACJ,IAAI,CAAC;IAE/DK,OAAO,CAACC,GAAG,CAAC,qBAAqB,EAAEL,iBAAiB,CAAC;EACvD,CAAC;EAED,oBACEb,MAAA,CAAAO,OAAA,CAAAY,aAAA,CAAChB,mBAAA,CAAAiB,OAAO;IACNC,GAAG,EAAEA,CAAA,KAAM,CAAC,CAAE;IACdC,MAAM,EACJC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GACjBtB,OAAO,CAAC,cAAc,CAAC,GACvB;MAAEuB,GAAG,EAAE;IAAmC,CAC/C;IACDC,eAAe,EAAE,CAAC,GAAG,CAAE;IACvBC,oBAAoB,EAAE,IAAK;IAC3BC,YAAY,EAAE,IAAK;IACnBC,eAAe,EAAE,IAAK;IACtBC,iBAAiB,EAAE,IAAK;IACxBC,wBAAwB,EAAE;IAC1B;IACA;IAAA;IACAC,SAAS,EAAGC,cAAc,IAAK;MAC7B;MACA,MAAM;QAAEjB;MAAY,CAAC,GAAGiB,cAAc;MACtChB,OAAO,CAACC,GAAG,CAACF,WAAW,CAACkB,OAAO,CAAC;IAClC,CAAE;IACFC,iBAAiB,EAAE,IAAK;IACxBC,OAAO,EAAGC,EAAE,IAAK;MACfpB,OAAO,CAACC,GAAG,CAACmB,EAAE,CAAC;IACjB,CAAE;IACFC,mBAAmB,EAAE;IACrB;IAAA;IACAC,kBAAkB,EAAE7B;IACpB;;IAEA;IAAA;IACAC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAAC,IAAA6B,QAAA,GAEahC,QAAQ;AAAAiC,OAAA,CAAAlC,OAAA,GAAAiC,QAAA"}
|
package/lib/commonjs/index.html
CHANGED
package/lib/commonjs/index.js
CHANGED
|
@@ -3,59 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Object.defineProperty(exports, "ErxesSDK", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _App.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _App = _interopRequireDefault(require("./App"));
|
|
10
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
const ErxesSDK = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
brandId,
|
|
14
|
-
src,
|
|
15
|
-
pollInterval = 6000
|
|
16
|
-
} = _ref;
|
|
17
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
18
|
-
const onMessage = data => {
|
|
19
|
-
const {
|
|
20
|
-
notificationCount
|
|
21
|
-
} = JSON.parse(data.nativeEvent.data);
|
|
22
|
-
console.log('****************** ', notificationCount);
|
|
23
|
-
};
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
25
|
-
source: _reactNative.Platform.OS === 'ios' ? require('./index.html') : {
|
|
26
|
-
uri: 'file:///android_asset/index.html'
|
|
27
|
-
},
|
|
28
|
-
originWhitelist: ['*'],
|
|
29
|
-
sharedCookiesEnabled: true,
|
|
30
|
-
cacheEnabled: true,
|
|
31
|
-
allowFileAccess: true,
|
|
32
|
-
domStorageEnabled: true,
|
|
33
|
-
thirdPartyCookiesEnabled: true
|
|
34
|
-
// allowingReadAccessToURL
|
|
35
|
-
// style={{ width: 200 }}
|
|
36
|
-
,
|
|
37
|
-
onLoadEnd: syntheticEvent => {
|
|
38
|
-
// update component to be aware of loading status
|
|
39
|
-
const {
|
|
40
|
-
nativeEvent
|
|
41
|
-
} = syntheticEvent;
|
|
42
|
-
console.log(nativeEvent.loading);
|
|
43
|
-
},
|
|
44
|
-
javaScriptEnabled: true,
|
|
45
|
-
onError: er => {
|
|
46
|
-
console.log(er);
|
|
47
|
-
},
|
|
48
|
-
startInLoadingState: true
|
|
49
|
-
// renderLoading={() => <Loader />}
|
|
50
|
-
,
|
|
51
|
-
injectedJavaScript: runFirst
|
|
52
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
53
|
-
|
|
54
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
55
|
-
,
|
|
56
|
-
onMessage: onMessage
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
var _default = ErxesSDK;
|
|
60
|
-
exports.default = _default;
|
|
61
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_App","_interopRequireDefault","require","obj","__esModule","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
const ErxesSDK = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
script
|
|
7
|
+
} = _ref;
|
|
8
|
+
const onMessage = data => {
|
|
9
|
+
const {
|
|
10
|
+
notificationCount
|
|
11
|
+
} = JSON.parse(data.nativeEvent.data);
|
|
12
|
+
console.log('****************** ', notificationCount);
|
|
13
|
+
};
|
|
14
|
+
return /*#__PURE__*/React.createElement(WebView, {
|
|
15
|
+
ref: () => {},
|
|
16
|
+
source: Platform.OS === 'ios' ? require('./index.html') : {
|
|
17
|
+
uri: 'file:///android_asset/index.html'
|
|
18
|
+
},
|
|
19
|
+
originWhitelist: ['*'],
|
|
20
|
+
sharedCookiesEnabled: true,
|
|
21
|
+
cacheEnabled: true,
|
|
22
|
+
allowFileAccess: true,
|
|
23
|
+
domStorageEnabled: true,
|
|
24
|
+
thirdPartyCookiesEnabled: true
|
|
25
|
+
// allowingReadAccessToURL
|
|
26
|
+
// style={{ width: 200 }}
|
|
27
|
+
,
|
|
28
|
+
onLoadEnd: syntheticEvent => {
|
|
29
|
+
// update component to be aware of loading status
|
|
30
|
+
const {
|
|
31
|
+
nativeEvent
|
|
32
|
+
} = syntheticEvent;
|
|
33
|
+
console.log(nativeEvent.loading);
|
|
34
|
+
},
|
|
35
|
+
javaScriptEnabled: true,
|
|
36
|
+
onError: er => {
|
|
37
|
+
console.log(er);
|
|
38
|
+
},
|
|
39
|
+
startInLoadingState: true
|
|
40
|
+
// renderLoading={() => <Loader />}
|
|
41
|
+
,
|
|
42
|
+
injectedJavaScript: script
|
|
43
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
44
|
+
|
|
45
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
46
|
+
,
|
|
47
|
+
onMessage: onMessage
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export default ErxesSDK;
|
|
51
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","WebView","Platform","ErxesSDK","_ref","script","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","ref","source","OS","require","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript"],"sourceRoot":"../../src","sources":["App.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,QAAQ,QAAQ,cAAc;AAMvC,MAAMC,QAA6B,GAAGC,IAAA,IAAgB;EAAA,IAAf;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAC/C,MAAME,SAAS,GAAIC,IAAS,IAAK;IAC/B,MAAM;MAAEC;IAAkB,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,WAAW,CAACJ,IAAI,CAAC;IAE/DK,OAAO,CAACC,GAAG,CAAC,qBAAqB,EAAEL,iBAAiB,CAAC;EACvD,CAAC;EAED,oBACER,KAAA,CAAAc,aAAA,CAACb,OAAO;IACNc,GAAG,EAAEA,CAAA,KAAM,CAAC,CAAE;IACdC,MAAM,EACJd,QAAQ,CAACe,EAAE,KAAK,KAAK,GACjBC,OAAO,CAAC,cAAc,CAAC,GACvB;MAAEC,GAAG,EAAE;IAAmC,CAC/C;IACDC,eAAe,EAAE,CAAC,GAAG,CAAE;IACvBC,oBAAoB,EAAE,IAAK;IAC3BC,YAAY,EAAE,IAAK;IACnBC,eAAe,EAAE,IAAK;IACtBC,iBAAiB,EAAE,IAAK;IACxBC,wBAAwB,EAAE;IAC1B;IACA;IAAA;IACAC,SAAS,EAAGC,cAAc,IAAK;MAC7B;MACA,MAAM;QAAEhB;MAAY,CAAC,GAAGgB,cAAc;MACtCf,OAAO,CAACC,GAAG,CAACF,WAAW,CAACiB,OAAO,CAAC;IAClC,CAAE;IACFC,iBAAiB,EAAE,IAAK;IACxBC,OAAO,EAAGC,EAAE,IAAK;MACfnB,OAAO,CAACC,GAAG,CAACkB,EAAE,CAAC;IACjB,CAAE;IACFC,mBAAmB,EAAE;IACrB;IAAA;IACAC,kBAAkB,EAAE5B;IACpB;;IAEA;IAAA;IACAC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAED,eAAeH,QAAQ"}
|
package/lib/module/index.html
CHANGED
package/lib/module/index.js
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { WebView } from 'react-native-webview';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
const ErxesSDK = _ref => {
|
|
5
|
-
let {
|
|
6
|
-
brandId,
|
|
7
|
-
src,
|
|
8
|
-
pollInterval = 6000
|
|
9
|
-
} = _ref;
|
|
10
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
11
|
-
const onMessage = data => {
|
|
12
|
-
const {
|
|
13
|
-
notificationCount
|
|
14
|
-
} = JSON.parse(data.nativeEvent.data);
|
|
15
|
-
console.log('****************** ', notificationCount);
|
|
16
|
-
};
|
|
17
|
-
return /*#__PURE__*/React.createElement(WebView, {
|
|
18
|
-
source: Platform.OS === 'ios' ? require('./index.html') : {
|
|
19
|
-
uri: 'file:///android_asset/index.html'
|
|
20
|
-
},
|
|
21
|
-
originWhitelist: ['*'],
|
|
22
|
-
sharedCookiesEnabled: true,
|
|
23
|
-
cacheEnabled: true,
|
|
24
|
-
allowFileAccess: true,
|
|
25
|
-
domStorageEnabled: true,
|
|
26
|
-
thirdPartyCookiesEnabled: true
|
|
27
|
-
// allowingReadAccessToURL
|
|
28
|
-
// style={{ width: 200 }}
|
|
29
|
-
,
|
|
30
|
-
onLoadEnd: syntheticEvent => {
|
|
31
|
-
// update component to be aware of loading status
|
|
32
|
-
const {
|
|
33
|
-
nativeEvent
|
|
34
|
-
} = syntheticEvent;
|
|
35
|
-
console.log(nativeEvent.loading);
|
|
36
|
-
},
|
|
37
|
-
javaScriptEnabled: true,
|
|
38
|
-
onError: er => {
|
|
39
|
-
console.log(er);
|
|
40
|
-
},
|
|
41
|
-
startInLoadingState: true
|
|
42
|
-
// renderLoading={() => <Loader />}
|
|
43
|
-
,
|
|
44
|
-
injectedJavaScript: runFirst
|
|
45
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
46
|
-
|
|
47
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
48
|
-
,
|
|
49
|
-
onMessage: onMessage
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
export default ErxesSDK;
|
|
1
|
+
export { default as ErxesSDK } from './App';
|
|
53
2
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["default","ErxesSDK"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAAQ,QAAQ,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAyCjC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type PropTypes = {
|
|
3
|
-
brandId: string;
|
|
4
|
-
src: string;
|
|
5
|
-
pollInterval?: number;
|
|
6
|
-
};
|
|
7
|
-
declare const ErxesSDK: React.FC<PropTypes>;
|
|
8
|
-
export default ErxesSDK;
|
|
1
|
+
export { default as ErxesSDK } from './App';
|
|
9
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,OAAO,CAAC"}
|
package/package.json
CHANGED
package/src/App.tsx
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export type PropTypes = {
|
|
6
|
+
script: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const ErxesSDK: React.FC<PropTypes> = ({ script }) => {
|
|
10
|
+
const onMessage = (data: any) => {
|
|
11
|
+
const { notificationCount } = JSON.parse(data.nativeEvent.data);
|
|
12
|
+
|
|
13
|
+
console.log('****************** ', notificationCount);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<WebView
|
|
18
|
+
ref={() => {}}
|
|
19
|
+
source={
|
|
20
|
+
Platform.OS === 'ios'
|
|
21
|
+
? require('./index.html')
|
|
22
|
+
: { uri: 'file:///android_asset/index.html' }
|
|
23
|
+
}
|
|
24
|
+
originWhitelist={['*']}
|
|
25
|
+
sharedCookiesEnabled={true}
|
|
26
|
+
cacheEnabled={true}
|
|
27
|
+
allowFileAccess={true}
|
|
28
|
+
domStorageEnabled={true}
|
|
29
|
+
thirdPartyCookiesEnabled={true}
|
|
30
|
+
// allowingReadAccessToURL
|
|
31
|
+
// style={{ width: 200 }}
|
|
32
|
+
onLoadEnd={(syntheticEvent) => {
|
|
33
|
+
// update component to be aware of loading status
|
|
34
|
+
const { nativeEvent } = syntheticEvent;
|
|
35
|
+
console.log(nativeEvent.loading);
|
|
36
|
+
}}
|
|
37
|
+
javaScriptEnabled={true}
|
|
38
|
+
onError={(er) => {
|
|
39
|
+
console.log(er);
|
|
40
|
+
}}
|
|
41
|
+
startInLoadingState={true}
|
|
42
|
+
// renderLoading={() => <Loader />}
|
|
43
|
+
injectedJavaScript={script}
|
|
44
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
45
|
+
|
|
46
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
47
|
+
onMessage={onMessage}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default ErxesSDK;
|
package/src/index.html
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { WebView } from 'react-native-webview';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export type PropTypes = {
|
|
6
|
-
brandId: string;
|
|
7
|
-
src: string;
|
|
8
|
-
pollInterval?: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const ErxesSDK: React.FC<PropTypes> = ({
|
|
12
|
-
brandId,
|
|
13
|
-
src,
|
|
14
|
-
pollInterval = 6000,
|
|
15
|
-
}) => {
|
|
16
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
17
|
-
|
|
18
|
-
const onMessage = (data: any) => {
|
|
19
|
-
const { notificationCount } = JSON.parse(data.nativeEvent.data);
|
|
20
|
-
|
|
21
|
-
console.log('****************** ', notificationCount);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<WebView
|
|
26
|
-
source={
|
|
27
|
-
Platform.OS === 'ios'
|
|
28
|
-
? require('./index.html')
|
|
29
|
-
: { uri: 'file:///android_asset/index.html' }
|
|
30
|
-
}
|
|
31
|
-
originWhitelist={['*']}
|
|
32
|
-
sharedCookiesEnabled={true}
|
|
33
|
-
cacheEnabled={true}
|
|
34
|
-
allowFileAccess={true}
|
|
35
|
-
domStorageEnabled={true}
|
|
36
|
-
thirdPartyCookiesEnabled={true}
|
|
37
|
-
// allowingReadAccessToURL
|
|
38
|
-
// style={{ width: 200 }}
|
|
39
|
-
onLoadEnd={(syntheticEvent) => {
|
|
40
|
-
// update component to be aware of loading status
|
|
41
|
-
const { nativeEvent } = syntheticEvent;
|
|
42
|
-
console.log(nativeEvent.loading);
|
|
43
|
-
}}
|
|
44
|
-
javaScriptEnabled={true}
|
|
45
|
-
onError={(er) => {
|
|
46
|
-
console.log(er);
|
|
47
|
-
}}
|
|
48
|
-
startInLoadingState={true}
|
|
49
|
-
// renderLoading={() => <Loader />}
|
|
50
|
-
injectedJavaScript={runFirst}
|
|
51
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
52
|
-
|
|
53
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
54
|
-
onMessage={onMessage}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default ErxesSDK;
|
|
1
|
+
export { default as ErxesSDK } from './App';
|