backButton listener

Hi all! I’m trying to disable hardware back button. I know it’s not a good practise, but I need to do it. I have following code:

import { App as AppSys } from '@capacitor/app';

AppSys.addListener('backButton', data => {
	console.log('hw back');

According to documentations:

Listening for this event will disable the default back button behaviour, so you might want to call window.history.back() manually

But it does not. I can see ‘hw back’ in log, but it does not disable default back button behaviour (it fires up log event and also it goes 1 step history back). What am I missing?

Are you using any framework?
Some frameworks might be already listening for backButton event and doing their own thing.

I’m using ionicframework with vuejs.

Then I think Ionic Framework adds a backButton listener, you can try to run AppSys.removeAllListeners() and then add your own listener, or read Ionic docs about how to handle the back button

Thanks you. You’re right. Ionicframework has own solution for hardware back button.

So if someone will have same issue, here is link: