cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

Android Disable Back Button Option

Open FBNitro opened this issue 6 years ago • 1 comments

Feature Request

Option to disable the Android hardware back button functionality.

Motivation Behind Feature

I have an app in which I have disabled the back button. I use keycloak-js as my authentication mechanism. When the user starts the authentication process, keycloak-js spawns the inappbrowser. I do not want the user to be able to hit the back button once the inappbrowser has opened.

On iOS, setting "toolbar: no" makes it impossible to go back, but on Android because of the current "harwareback" implementation, this is not possible.

The "hardwareback" option currently allows back to either go back, or close the inappbrowser, neither option are equivalent to the iOS setup where I cannot go back.

Feature Description

Add a new android option for hardwarebackdisabled: yes/no, defaults to no. I suggest a new option since changing the hardwareback would break compatibility,

Alternatives or Workarounds

I have no workarounds at this time.

FBNitro avatar Apr 24 '19 17:04 FBNitro

AS Workaround temporary commented via patch

diff --git a/./platforms/android/app/src/main/java/org/apache/cordova/inappbrowser/InAppBrowserDialog.java b/./platforms/android/app/src/main/java/org/apache/cordova/inappbrowser/InAppBrowserDialog.java
--- a/./platforms/android/app/src/main/java/org/apache/cordova/inappbrowser/InAppBrowserDialog.java
+++ b/./platforms/android/app/src/main/java/org/apache/cordova/inappbrowser/InAppBrowserDialog.java
@@ -49,9 +49,9 @@ public class InAppBrowserDialog extends Dialog {
             // because it does a clean up
             if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
                 this.inAppBrowser.goBack();
-            }  else {
-                this.inAppBrowser.closeDialog();
-            }
+            //}  else {
+            //    this.inAppBrowser.closeDialog();
+            //}
         }
     }
 }

Delagen avatar Dec 27 '21 12:12 Delagen