@btsd/aitu-bridge 0.3.44 → 0.3.45

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
@@ -151,6 +151,7 @@ export interface AituBridge {
151
151
  openPayment: (transactionId: string) => Promise<ResponseType>;
152
152
  setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
153
153
  checkBiometry: () => Promise<ResponseType>;
154
+ openExternalUrl: (url: string) => Promise<ResponseType>;
154
155
  }
155
156
 
156
157
  const invokeMethod = 'invoke';
@@ -179,6 +180,7 @@ const setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';
179
180
  const openPaymentMethod = 'openPayment'
180
181
  const setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';
181
182
  const checkBiometryMethod = 'checkBiometry';
183
+ const openExternalUrlMethod = 'openExternalUrl';
182
184
 
183
185
  const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
184
186
  const ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;
@@ -622,6 +624,19 @@ const buildBridge = (): AituBridge => {
622
624
  }
623
625
  }
624
626
 
627
+ const openExternalUrl = (reqId, url: string) => {
628
+ const isAndroid = android && android[openExternalUrlMethod];
629
+ const isIos = ios && ios[openExternalUrlMethod];
630
+
631
+ if (isAndroid) {
632
+ android[openExternalUrlMethod](reqId, url);
633
+ } else if (isIos) {
634
+ ios[openExternalUrlMethod].postMessage({ reqId, url });
635
+ } else {
636
+ console.log("--openExternalUrlMethod-isUnknown");
637
+ }
638
+ };
639
+
625
640
 
626
641
  const invokePromise = promisifyInvoke(invoke, sub);
627
642
  const storagePromise = promisifyStorage(storage, sub);
@@ -645,6 +660,7 @@ const buildBridge = (): AituBridge => {
645
660
  const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);
646
661
  const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);
647
662
  const checkBiometryPromise = promisifyMethod(checkBiometry, checkBiometryMethod, sub);
663
+ const openExternalUrlPromise = promisifyMethod(openExternalUrl, openExternalUrlMethod, sub);
648
664
 
649
665
  return {
650
666
  version: String(LIB_VERSION),
@@ -657,12 +673,15 @@ const buildBridge = (): AituBridge => {
657
673
  getGeo: getGeoPromise,
658
674
  getQr: getQrPromise,
659
675
  getSMSCode: getSMSCodePromise,
660
- getUserProfile: (id: string) => invokePromise(EInvokeRequest.getUserProfile, { id }),
676
+ getUserProfile: (id: string) =>
677
+ invokePromise(EInvokeRequest.getUserProfile, { id }),
661
678
  selectContact: selectContactPromise,
662
679
  enableNotifications,
663
680
  disableNotifications,
664
- enablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),
665
- disablePrivateMessaging: (appId: string) => invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),
681
+ enablePrivateMessaging: (appId: string) =>
682
+ invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),
683
+ disablePrivateMessaging: (appId: string) =>
684
+ invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),
666
685
  openSettings: openSettingsPromise,
667
686
  closeApplication: closeApplicationPromise,
668
687
  setTitle: setTitlePromise,
@@ -685,7 +704,8 @@ const buildBridge = (): AituBridge => {
685
704
  openPayment: openPaymentPromise,
686
705
  setCustomBackArrowOnClickHandler,
687
706
  checkBiometry: checkBiometryPromise,
688
- }
707
+ openExternalUrl: openExternalUrlPromise,
708
+ };
689
709
  }
690
710
 
691
711
  const bridge = buildBridge();
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.3.44";
1
+ export const LIB_VERSION = "0.3.45";