capacitor-inappbrowser icon indicating copy to clipboard operation
capacitor-inappbrowser copied to clipboard

feat: More control of back button presses on the parent page

Open SystemParadox opened this issue 3 weeks ago • 0 comments

Feature Request

Description

At the moment it seems that InAppBrowser.openWebView captures all events from the Android back button.

If you set disableGoBackOnNativeApplication: true then it just prevents the webview from closing, but the parent app never gets any events, neither from @capacitor/app App.addEventListener('backButton'), nor from Android's onBackPressed method or getOnBackInvokedDispatcher().registerOnBackInvokedCallback.

Platform(s)

Android

Preferred Solution

If the app can't go back any more, or disableGoBackOnNativeApplication is true, then pass the back button press event up to the parent activity.

Possibly as simple as changing InAppBrowserPlugin.onBackPressed in to call super.onBackPressed() in an else?

Alternatives

Allow the parent page to hook into an onBackPressed event or similar.

To be honest it would be nice if the parent page could always intercept the back event, so that we can trigger actions like escaping back to the main capacitor app if you tap back 3 times, regardless of what the WebView is doing.

SystemParadox avatar Nov 03 '25 16:11 SystemParadox