Skip to content

Conversation

@theproducer
Copy link
Contributor

@theproducer theproducer commented Jul 25, 2025

Adds a new configuration and runtime toggle for toggling on and off the App plugin's Android back button handling.

Disabling back button handling allows things like Android 13+ predictive back gesture to work.

closes: ionic-team/capacitor#6293

@github-actions
Copy link

github-actions bot commented Jul 25, 2025

Released dev build of app with dev version: 7.0.3-dev-2390-20250902T150300.0

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding the this.onbackPressedCallback = callback; new line, set it on the callback creation changing OnBackPressedCallback callback = new OnBackPressedCallback(true) to this.onbackPressedCallback = new OnBackPressedCallback(true) (will also need to replace other usages of callback to this.onbackPressedCallback`

While this is supposed to enable the predictive back on Android 15+, this disables the back button handling for all Android versions, so I think that should be documented as for the current comment, it appears to only have an effect on Android 15+, but it affects all Android versions.

I don't fully understand what the "predictive back" is supposed to do, I see no difference on enabling it or disabling it, other than the back button handling not being into effect, which leads to the app being minimized instead of navigating back.

@jcesarmobile
Copy link
Member

Also, I think this should be configurable from the capacitor config file to disable it from the beginning if desired, and the name should probably be about disabling back button handling as this is what the PR really does, which is required for predictive back to work, but you are disabling the back button handling in the end and people might want to use the app plugin just for the app information and not for the back button handling.

@theproducer
Copy link
Contributor Author

Also, I think this should be configurable from the capacitor config file to disable it from the beginning if desired, and the name should probably be about disabling back button handling as this is what the PR really does, which is required for predictive back to work, but you are disabling the back button handling in the end and people might want to use the app plugin just for the app information and not for the back button handling.

I think you are right, especially the part about people may not wanting the back button handling from the plugin at all.

I'll make those changes, and I'll keep the toggle as well (renaming it to be more generic) in case there are scenarios where devs want to temporarily enable / disable back button handling based on the state / routing of their app.

@theproducer theproducer changed the title feat(app): Add support enabling predictive back gesture on Android feat(app): Add support for toggling Android back button handling Jul 31, 2025
@theproducer theproducer requested a review from jcesarmobile July 31, 2025 16:52
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new configuration is not documented, you can add this to the README to get it generated automatically

## Configuration

<docgen-config>
</docgen-config>

or you can add it manually if the generation causes issues

app/package.json Outdated
"@capacitor/core": "^7.0.0",
"@capacitor/docgen": "0.2.2",
"@capacitor/ios": "^7.0.0",
"@capacitor/cli": "^7.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should go over @capacitor/core, if not it will be moved automatically in the future if some dependency gets installed or uninstalled

@theproducer theproducer merged commit 6c56293 into main Sep 2, 2025
9 checks passed
@theproducer theproducer deleted the RDMR-833 branch September 2, 2025 15:17
sbgitZZ added a commit to sbgitZZ/capacitor-plugins that referenced this pull request Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add support for Predictive Back Gestures

5 participants