Skip to content

Commit

Permalink
fix: hardware back button issue
Browse files Browse the repository at this point in the history
  • Loading branch information
akmalhisyammm committed Dec 7, 2021
1 parent 3e49bcd commit 6cdc324
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.Bundle;
import android.webkit.WebSettings;

import com.capacitorjs.plugins.app.AppPlugin;
import com.capacitorjs.plugins.camera.CameraPlugin;
import com.capacitorjs.plugins.geolocation.GeolocationPlugin;
import com.capacitorjs.plugins.splashscreen.SplashScreenPlugin;
Expand Down Expand Up @@ -53,6 +54,7 @@ public void onCreate(Bundle savedInstanceState) {
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(AppPlugin.class);
add(CameraPlugin.class);
add(GeolocationPlugin.class);
add(SplashScreenPlugin.class);
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.google.gms:google-services:4.3.5'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect } from 'react';
import { IonApp, IonSplitPane } from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import { SplashScreen } from '@capacitor/splash-screen';
import { App as CapacitorApp } from '@capacitor/app';

import Routes from 'components/routes/Routes';
import SideMenu from 'components/SideMenu';
Expand All @@ -26,6 +27,10 @@ import '@ionic/react/css/display.css';
import 'theme/variables.css';
import 'theme/customTheme.css';

CapacitorApp.addListener('backButton', ({ canGoBack }) => {
!canGoBack ? CapacitorApp.exitApp() : window.history.back();
});

const App: React.FC = () => {
useEffect(() => {
setTimeout(() => {
Expand Down

0 comments on commit 6cdc324

Please sign in to comment.