RaphaelWoude / capacitor-native-settings

Capacitor plugin to open native settings screens for android and iOS
MIT License
92 stars 30 forks source link

How to return into app? #49

Closed sqf147 closed 3 months ago

sqf147 commented 4 months ago

My app will jump to a page if network not connected, showing users a button to open WIFI settings. try { const result = await NativeSettings.openAndroid({ option: AndroidSettings.Wifi }) console.log(result) } catch (e) { console.log(e) } how to return into app when user click the back button on the top left corner after setting wifi connections. (Android) my app had an eventlistener to check connections, or if network reconnected, how to bring the app into the front? Network.addListener('networkStatusChange', status => { console.log('Network status changed', status); if (status.connected) { // how to bring app into front? user jumped to settings.wifi } }); Thank you. NativeSettings.openAndroid returns a promise, but I didn't find out the use of the return value.

sqf147 commented 4 months ago

find a alternative way, window.setInterval will work in background, then use app-launcher plugin to bring app foreground. import { AppLauncher } from '@capacitor/app-launcher'; const intervalId = ref(0) NativeSettings.openAndroid({ option: AndroidSettings.Wifi }) intervalId.value = window.setInterval(async () => { const status = await Network.getStatus(); if (status.connected) { await AppLauncher.openUrl({ url: 'com.test.app' }); //your app bundle id } }, 3000)

RaphaelWoude commented 3 months ago

The back button should get you back into your app