Reputation: 3297
I'm using Ionic 5 in my pwa application (angular framework), and I want to close the opening modal/popover (if exist) when the user uses the hardware back button..
I couldn't find any solution online that works on ionic 4+ pwa applications.
Any help will be appreciated.
Upvotes: 2
Views: 1327
Reputation: 1175
You can add a handler for the backbutton.
Cordova: Inject Platform in a constructor and
this.platform.backButton.subscribe(() => {
// close modal here
});
Capacitor:
import { Plugins, AppState } from '@capacitor/core';
const { App } = Plugins;
App.addListener('backButton', () => {
// close modal here
});
Upvotes: 2