Skip to content

Commit

Permalink
Merge pull request #11463 from JohnathanWhite/feat/upgrade-iab
Browse files Browse the repository at this point in the history
[FIX] java.lang.IllegalArgumentException IAB
  • Loading branch information
cmgustavo authored Jan 27, 2021
2 parents 667c586 + 3d787c5 commit 8f87ee8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"cordova-plugin-fcm-ng": "8.2.0",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-globalization": "1.0.9",
"cordova-plugin-inappbrowser": "3.2.0",
"cordova-plugin-inappbrowser": "4.1.0",
"cordova-plugin-ionic-keyboard": "2.1.3",
"cordova-plugin-qrscanner": "3.0.1",
"cordova-plugin-screen-orientation": "3.0.2",
Expand Down
11 changes: 10 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export class CopayApp {
if (!lockMethod || lockMethod === 'disabled') {
return;
}
this.iabCardProvider.pause();
});

this.logger.debug('BitPay: setting network');
Expand Down Expand Up @@ -467,6 +466,7 @@ export class CopayApp {
} else if (lockMethod == 'fingerprint') {
this.openFingerprintModal();
}
this.iabCardProvider.pause();
}

private openPINModal(action): void {
Expand All @@ -480,6 +480,9 @@ export class CopayApp {
}
);
modal.present({ animate: false });
modal.onWillDismiss(() => {
this.onLockWillDismiss();
});
modal.onDidDismiss(() => {
this.onLockDidDismiss();
});
Expand All @@ -496,6 +499,9 @@ export class CopayApp {
}
);
modal.present({ animate: false });
modal.onWillDismiss(() => {
this.onLockWillDismiss();
});
modal.onDidDismiss(() => {
this.onLockDidDismiss();
});
Expand All @@ -505,6 +511,9 @@ export class CopayApp {
this.appProvider.isLockModalOpen = false;
this.events.publish('Local/FetchWallets');
this.events.publish('Local/showNewFeaturesSlides');
}

private onLockWillDismiss(): void {
this.iabCardProvider.resume();
}

Expand Down
9 changes: 7 additions & 2 deletions src/providers/in-app-browser/in-app-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ActionSheetProvider } from '../../providers/action-sheet/action-sheet';
import { Logger } from '../../providers/logger/logger';
import { OnGoingProcessProvider } from '../../providers/on-going-process/on-going-process';

declare var cordova: any;

@Injectable()
export class InAppBrowserProvider {
// add new refs here
Expand Down Expand Up @@ -44,8 +46,11 @@ export class InAppBrowserProvider {
initScript?: string
): Promise<InAppBrowserRef> {
return new Promise((res, rej) => {
const ref: InAppBrowserRef = window.open(url, '_blank', config);
ref.postMessage = window.postMessage;
const ref: InAppBrowserRef = cordova.InAppBrowser.open(
url,
'_blank',
config
);

const initCb = () => {
if (initScript) {
Expand Down
27 changes: 6 additions & 21 deletions utils/iab-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,14 @@

const fs = require('fs');

try {
const file = `${__dirname}/../platforms/ios/BitPay/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowserNavigationController.m`;
const content = fs.readFileSync(file, 'utf8');

if (content.includes('20.0')) {
const result = content.replace(/20.0/g, '0');
fs.writeFileSync(file, result);
console.log('successfully patched ios status bar height');
}
} catch (err) {
console.error(err);
}

try {
const file = `${__dirname}/../platforms/ios/BitPay/Plugins/cordova-plugin-inappbrowser/CDVWKInAppBrowser.m`;
const content = fs
.readFileSync(file, 'utf8')
.split('#define LOCATIONBAR_HEIGHT 21.0');
if (content[0].includes('20.0')) {
const result =
content[0].replace(/20.0/g, '0') +
'#define LOCATIONBAR_HEIGHT 21.0' +
content[1];
const content = fs.readFileSync(file, 'utf8');
if (content.includes('(float) getStatusBarOffset')) {
const result = content.replace(
/\(float\) IsAtLeastiOSVersion\(@"7.0"\) \? \[\[UIApplication sharedApplication] statusBarFrame].size.height : 0.0;/g,
'0.0;'
);
fs.writeFileSync(file, result);
console.log('successfully patched WK status bar height');
}
Expand Down

0 comments on commit 8f87ee8

Please sign in to comment.