@@ -10,17 +10,22 @@ import '../styles/globals.css'
1010import { Major_Mono_Display } from 'next/font/google'
1111import clsx from 'clsx'
1212import { initTracking } from 'web/lib/service/analytics'
13- import WebPush from "web/lib/service/web-push" ;
14- import AndroidPush from "web/lib/service/android-push" ;
15- import { isAndroidWebView } from "web/lib/util/webview" ;
16- import { Capacitor } from '@capacitor/core' ;
17- import { StatusBar } from '@capacitor/status-bar' ;
13+ import WebPush from "web/lib/service/web-push"
14+ import AndroidPush from "web/lib/service/android-push"
15+ import { isAndroidWebView } from "web/lib/util/webview"
16+ import { Capacitor } from '@capacitor/core'
17+ import { StatusBar } from '@capacitor/status-bar'
18+ import { App } from '@capacitor/app'
19+ import { useRouter } from "next/navigation" ;
1820
1921if ( Capacitor . isNativePlatform ( ) ) {
2022 // Only runs on iOS/Android native
2123 // Note sure it's doing anything, though, need to check
22- StatusBar . setOverlaysWebView ( { overlay : false } ) . catch ( console . warn ) ;
23- // StatusBar.setStyle({style: Style.Light}).catch(console.warn);
24+ StatusBar . setOverlaysWebView ( { overlay : false } ) . catch ( console . warn )
25+ // StatusBar.setStyle({style: Style.Light}).catch(console.warn)
26+ App . addListener ( 'backButton' , ( { canGoBack} ) => {
27+ window . dispatchEvent ( new CustomEvent ( 'appBackButton' ) )
28+ } )
2429}
2530
2631
@@ -63,6 +68,7 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
6368 console . log ( 'isAndroidWebView app:' , isAndroidWebView ( ) )
6469 useEffect ( printBuildInfo , [ ] )
6570 useHasLoaded ( )
71+ const router = useRouter ( )
6672
6773 useEffect ( ( ) => {
6874 initTracking ( )
@@ -75,10 +81,19 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
7581 }
7682 } , [ ] )
7783
84+ useEffect ( ( ) => {
85+ const handleBack = ( ) => {
86+ router . back ( )
87+ }
88+
89+ window . addEventListener ( 'appBackButton' , handleBack )
90+ return ( ) => window . removeEventListener ( 'appBackButton' , handleBack )
91+ } , [ router ] )
92+
7893 // useEffect(() => {
7994 // // Expose globally for native bridge
80- // (window as any).oauthRedirect = oauthRedirect;
81- // }, []);
95+ // (window as any).oauthRedirect = oauthRedirect
96+ // }, [])
8297
8398 const title = 'Compass'
8499 const description = 'The platform for intentional connections'
0 commit comments