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

feat: appStateChange event should have more states than just isActive #1153

Closed
rbtprograms opened this issue Jan 9, 2021 · 3 comments · Fixed by #1220
Closed

feat: appStateChange event should have more states than just isActive #1153

rbtprograms opened this issue Jan 9, 2021 · 3 comments · Fixed by #1220

Comments

@rbtprograms
Copy link

Feature Request

Description

appStateChange only having isActive as a state feels limited. For instance, appState.isActive will return false on iOS when control center is opened or faceId is used. I understand that this technically means the app is not in focus, but that doesn't mean is the app isn't active. This has been particularly challenging when trying to code for when a user switches to a different application and then requesting they re-authenticate, but this can get triggered by any number of menus being pulled up. Having one blanket boolean for all the times your app is not in scope is too limited, and it would feel a lot more robust if there were other states to track, such as if other native menus were open, whether our app was truly minimized, etc.

Platform(s)

Android, iOS. I haven't considered how much this could effect web or desktop, but it is definitely difficult to work with on mobile platforms.

Preferred Solution

There should be a way to know if your app is currently not active but hasn't actually been minimized or another app has been selected. Having state.isActive be equivalent whether control center is pulled up or the app is minimized is just too limited.

Alternatives

I honestly can't think of a great solution. The only thing I have figured out is to not show biometrics within a long timeout period, figuring that should cover any menu openings or biometrics being ran.

Additional Context

https://capacitorjs.com/docs/apis/app#addlistener
Definitely could use more nuance.

@daevst
Copy link

daevst commented May 5, 2021

Hello , yeah i would like to have more states too , i am challenging an issue with the app event because i need the urls opened to a external browser inside my app , and that made me investigate more than a week for how i would check those requests

@jamesonsaunders
Copy link

I agree, would be useful to have more states. Ideas:

  • Active
  • Active_And_Hidden
  • Inactive

My use case is I'm tracking session time, and when the user opens the in app browser it fires an app state change event for INACTIVE (on android only). I have no way of telling whether the user left the app, or just opened the in app browser.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 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 the plugin, 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 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants