@btsd/aitu-bridge 0.3.1 → 0.3.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/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +18 -8
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -14,7 +14,9 @@ enum EInvokeRequest {
|
|
|
14
14
|
getContacts = 'GetContacts',
|
|
15
15
|
getUserProfile = 'GetUserProfile',
|
|
16
16
|
enableNotifications = 'AllowNotifications',
|
|
17
|
-
disableNotifications = 'DisableNotifications'
|
|
17
|
+
disableNotifications = 'DisableNotifications',
|
|
18
|
+
enablePrivateMessaging = 'EnablePrivateMessaging',
|
|
19
|
+
disablePrivateMessaging = 'DisablePrivateMessaging',
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
type SetItemType = (keyName: string, keyValue: string) => Promise<void>;
|
|
@@ -127,6 +129,8 @@ export interface AituBridge {
|
|
|
127
129
|
shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;
|
|
128
130
|
enableNotifications: () => Promise<{}>;
|
|
129
131
|
disableNotifications: () => Promise<{}>;
|
|
132
|
+
enablePrivateMessaging: (appId: string) => Promise<string>;
|
|
133
|
+
disablePrivateMessaging: (appId: string) => Promise<string>;
|
|
130
134
|
openSettings: () => Promise<OpenSettingsResponse>;
|
|
131
135
|
closeApplication: () => Promise<ResponseType>;
|
|
132
136
|
setShakeHandler: (handler: any) => void;
|
|
@@ -182,13 +186,17 @@ const buildBridge = (): AituBridge => {
|
|
|
182
186
|
[...subs].map((fn) => fn.call(null, e));
|
|
183
187
|
})
|
|
184
188
|
|
|
185
|
-
window.addEventListener('message', (e)=>{
|
|
189
|
+
window.addEventListener('message', (e) => {
|
|
190
|
+
if(typeof e.data !== 'string') {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
186
194
|
const message = JSON.parse(e.data)
|
|
187
195
|
|
|
188
|
-
if(message && message['method']){
|
|
189
|
-
if(message.method === 'setCustomBackArrowOnClickHandler'){
|
|
196
|
+
if (message && message['method']) {
|
|
197
|
+
if (message.method === 'setCustomBackArrowOnClickHandler') {
|
|
190
198
|
(window as any).onAituBridgeBackArrowClick()
|
|
191
|
-
}else if(message.method === 'setHeaderMenuItemClickHandler'){
|
|
199
|
+
} else if (message.method === 'setHeaderMenuItemClickHandler') {
|
|
192
200
|
(window as any).onAituBridgeHeaderMenuItemClick(message.param)
|
|
193
201
|
}
|
|
194
202
|
}
|
|
@@ -485,7 +493,7 @@ const buildBridge = (): AituBridge => {
|
|
|
485
493
|
android[vibrateMethod](reqId, JSON.stringify(pattern));
|
|
486
494
|
} else if (isIos) {
|
|
487
495
|
ios[vibrateMethod].postMessage({ reqId, pattern });
|
|
488
|
-
}
|
|
496
|
+
} else if (web) {
|
|
489
497
|
web.execute(vibrateMethod, reqId, pattern);
|
|
490
498
|
} else if (typeof window !== 'undefined') {
|
|
491
499
|
console.log('--vibrate-isUnknown');
|
|
@@ -591,7 +599,7 @@ const buildBridge = (): AituBridge => {
|
|
|
591
599
|
|
|
592
600
|
if (isAndroid || isIos || web) {
|
|
593
601
|
(window as any).onAituBridgeBackArrowClick = handler;
|
|
594
|
-
}else if (typeof window !== 'undefined') {
|
|
602
|
+
} else if (typeof window !== 'undefined') {
|
|
595
603
|
console.log('--setCustomBackArrowOnClickHandler-isUnknown');
|
|
596
604
|
}
|
|
597
605
|
}
|
|
@@ -616,7 +624,7 @@ const buildBridge = (): AituBridge => {
|
|
|
616
624
|
const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);
|
|
617
625
|
const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);
|
|
618
626
|
const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);
|
|
619
|
-
const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible,setCustomBackArrowVisibleMethod, sub);
|
|
627
|
+
const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);
|
|
620
628
|
|
|
621
629
|
return {
|
|
622
630
|
version: String(LIB_VERSION),
|
|
@@ -633,6 +641,8 @@ const buildBridge = (): AituBridge => {
|
|
|
633
641
|
selectContact: selectContactPromise,
|
|
634
642
|
enableNotifications,
|
|
635
643
|
disableNotifications,
|
|
644
|
+
enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),
|
|
645
|
+
disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),
|
|
636
646
|
openSettings: openSettingsPromise,
|
|
637
647
|
closeApplication: closeApplicationPromise,
|
|
638
648
|
setTitle: setTitlePromise,
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.3.
|
|
1
|
+
export const LIB_VERSION = "0.3.3";
|