backbutton not working even after fix #8079
Replies: 1 comment 1 reply
|
I read through this.onBackPressedCallback = new OnBackPressedCallback(!disableBackButtonHandler) {
@Override
public void handleOnBackPressed() {
if (!hasListeners(EVENT_BACK_BUTTON)) {
if (bridge.getWebView().canGoBack()) {
bridge.getWebView().goBack();
}
} else {
JSObject data = new JSObject();
data.put("canGoBack", bridge.getWebView().canGoBack());
notifyListeners(EVENT_BACK_BUTTON, data, true);
bridge.triggerJSEvent("backbutton", "document");
}
}
};The important part: this is registered as an I also checked Given that, the most likely explanation for "exits regardless of the dialog answer" is that the listener is getting registered more than once, if For the App.addListener('backButton', (event) => {
if (event.canGoBack) {
window.history.back();
} else if (confirm('Are you sure you want to exit the app?')) {
App.exitApp();
}
});The snippet in your post cuts off right after |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
├── @capacitor/android@7.4.2
├── @capacitor/app@7.0.1
├── @capacitor/core@7.4.2
I have a single page app using capacitor + webpack that navigates pages with window.pageStack.push(page)
and i tried the overriding the backbutton like:
but it always exits on cancel or when canGoBack is true and window.history.back()
All reactions