refactor: add android back button

This commit is contained in:
Esteban Abaroa
2024-01-31 21:44:17 +00:00
parent f58827a0aa
commit 6a95cf031e

View File

@@ -5,6 +5,7 @@ import { HashRouter as Router } from 'react-router-dom';
import './lib/init-translations';
import './index.css';
import './themes.css';
import { App as CapacitorApp } from '@capacitor/app';
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
@@ -14,3 +15,12 @@ root.render(
</Router>
</React.StrictMode>,
);
// add back button in android app
CapacitorApp.addListener('backButton', ({ canGoBack }) => {
if (canGoBack) {
window.history.back();
} else {
CapacitorApp.exitApp();
}
});