@btsd/aitu-bridge 0.3.3 → 0.3.41

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/src/index.ts CHANGED
@@ -37,6 +37,8 @@ interface GetMeResponse {
37
37
  id: string;
38
38
  avatar?: string;
39
39
  avatarThumb?: string;
40
+ notifications_allowed: boolean;
41
+ private_messaging_enabled: boolean;
40
42
  sign: string;
41
43
  }
42
44
 
@@ -146,6 +148,7 @@ export interface AituBridge {
146
148
  setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;
147
149
  getCustomBackArrowMode: () => Promise<boolean>;
148
150
  setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
151
+ openPayment: (transactionId: string) => Promise<ResponseType>;
149
152
  setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
150
153
  }
151
154
 
@@ -172,6 +175,7 @@ const setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';
172
175
  const setCustomBackArrowModeMethod = 'setCustomBackArrowMode';
173
176
  const getCustomBackArrowModeMethod = 'getCustomBackArrowMode';
174
177
  const setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';
178
+ const openPaymentMethod = 'openPayment'
175
179
  const setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';
176
180
 
177
181
  const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
@@ -187,7 +191,7 @@ const buildBridge = (): AituBridge => {
187
191
  })
188
192
 
189
193
  window.addEventListener('message', (e) => {
190
- if(typeof e.data !== 'string') {
194
+ if (typeof e.data !== 'string') {
191
195
  return;
192
196
  }
193
197
 
@@ -604,6 +608,19 @@ const buildBridge = (): AituBridge => {
604
608
  }
605
609
  }
606
610
 
611
+ const openPayment = (reqId, transactionId: string) => {
612
+ const isAndroid = android && android[openPaymentMethod];
613
+ const isIos = ios && ios[openPaymentMethod];
614
+
615
+ if (isAndroid) {
616
+ android[openPaymentMethod](reqId, transactionId);
617
+ } else if (isIos) {
618
+ ios[openPaymentMethod].postMessage({ reqId, transactionId });
619
+ } else {
620
+ console.log('--openPayment-isUnknown');
621
+ }
622
+ }
623
+
607
624
 
608
625
  const invokePromise = promisifyInvoke(invoke, sub);
609
626
  const storagePromise = promisifyStorage(storage, sub);
@@ -625,6 +642,7 @@ const buildBridge = (): AituBridge => {
625
642
  const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);
626
643
  const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);
627
644
  const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);
645
+ const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);
628
646
 
629
647
  return {
630
648
  version: String(LIB_VERSION),
@@ -662,6 +680,7 @@ const buildBridge = (): AituBridge => {
662
680
  setCustomBackArrowMode: setCustomBackArrowModePromise,
663
681
  getCustomBackArrowMode: getCustomBackArrowModePromise,
664
682
  setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,
683
+ openPayment: openPaymentPromise,
665
684
  setCustomBackArrowOnClickHandler,
666
685
  }
667
686
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.3.3";
1
+ export const LIB_VERSION = "0.3.41";