Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Get current appState at any moment #2500

Closed
4 tasks done
Finesse opened this issue Feb 28, 2020 · 1 comment · Fixed by #2611
Closed
4 tasks done

feat: Get current appState at any moment #2500

Finesse opened this issue Feb 28, 2020 · 1 comment · Fixed by #2611

Comments

@Finesse
Copy link

Finesse commented Feb 28, 2020

Feature Request

Describe the Feature Request

There is a way to get a call back when the application goes background or foreground. But there is no way to get the application isActive value (a.k.a. foreground/background state) at any moment. The problem is that I don't know the application state until I subscribe to the appStateChange event AND the app goes background or foreground. JavaScript can start working while the app is in background (e.g. when you minimize the app during the splash screen) so I can't just say «it's foreground initially».

Platform Support Requested

  • Android
  • iOS
  • Electron
  • Web

Describe Preferred Solution

Add a method to the App plugin:

App.getAppState(); // returns an AppState instance

Related Code

let appState: AppState = {
  isActive: ???
};

App.addListener('appStateChange', newState => appState = newState);

Additional Context

https://stackoverflow.com/q/60435042/1118709

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant