Skip to content

Commit

Permalink
Fixed issue with error when trying to check if "custom tabs" are avai…
Browse files Browse the repository at this point in the history
…lable (in cordova-plugin-safariviewcontroller).

Link to issue resolved here:
EddyVerbruggen/cordova-plugin-safariviewcontroller#179
  • Loading branch information
ingljo committed Aug 26, 2021
1 parent f0666ce commit 7b3cbc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
<platform name="android">
<allow-navigation href="http://localhost:8080/*" />
<allow-intent href="market:*" />
<config-file parent="/manifest" target="AndroidManifest.xml">
<queries>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
</config-file>
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:allowBackup="false" />
<application android:fullBackupContent="false" />
Expand Down
7 changes: 3 additions & 4 deletions src/app/modules/auth/cordova-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export class CordovaBrowser extends Browser {
private inAppBrowserRef: InAppBrowserObject | undefined;

private async useSafariViewController(): Promise<boolean> {
const isSafariViewControllerAvailable = await this.safariViewController.isAvailable(); // Also returns true for Android chrome custom tabs
return this.platform.is('ios') && isSafariViewControllerAvailable;
return await this.safariViewController.isAvailable(); // Also returns true for Android chrome custom tabs
}

public async closeWindow(): Promise<void> {
Expand All @@ -43,7 +42,7 @@ export class CordovaBrowser extends Browser {
}

public async showWindow(url: string): Promise<string | undefined> {
if (this.useSafariViewController()) {
if (await this.useSafariViewController()) {
const optionSafari: any = {
url: url,
showDefaultShareMenuItem: false,
Expand All @@ -65,7 +64,7 @@ export class CordovaBrowser extends Browser {
clearsessioncache: 'yes'
};

this.inAppBrowserRef = this.inAppBrowser.create(url, '_self', options);
this.inAppBrowserRef = this.inAppBrowser.create(url, '_system', options);

if (this.inAppBrowserRef != undefined) {
this.inAppBrowserRef.on('exit').subscribe(() => this.onCloseFunction());
Expand Down

0 comments on commit 7b3cbc3

Please sign in to comment.