Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to return into app? #49

Closed
sqf147 opened this issue Jun 6, 2024 · 2 comments
Closed

How to return into app? #49

sqf147 opened this issue Jun 6, 2024 · 2 comments

Comments

@sqf147
Copy link

sqf147 commented Jun 6, 2024

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
Copy link
Author

sqf147 commented Jun 6, 2024

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
Copy link
Owner

The back button should get you back into your app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants