You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ npx cap doctor
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 1.3.0
@capacitor/core: 1.3.0
@capacitor/android: 1.3.0
@capacitor/ios: 1.3.0
Installed Dependencies:
@capacitor/cli 1.2.1
@capacitor/core 1.2.1
@capacitor/ios 1.2.1
@capacitor/android 1.2.1
Affected Platform(s)
Android
iOS
Electron
Web
Current Behavior
The appStateChange event of the App plugin behaves differently between Android and iOS. On Android the retainUntilConsumed flag is true, while on iOS it is false
This means that if your client JS code adds a listener for appStateChange it will fire on first app boot on Android but not on iOS.
Expected Behavior
Both platforms should behave the same. In our app we've found that we'd rather have the iOS behavior, which ensures the event doesn't fire on first app boot, only when the app resumes from the background.
Reproduction Steps
Create a new Capacitor app
Add a listener for appStateChange via the Capacitor App plugin
Have the handler log an even to the console
Launch the app on Android and iOS
See that the console log statement appears on Android, but not iOS.
The text was updated successfully, but these errors were encountered:
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.
Bug Report
Capacitor Version
npx cap doctor
output:Affected Platform(s)
Current Behavior
The
appStateChange
event of theApp
plugin behaves differently between Android and iOS. On Android theretainUntilConsumed
flag istrue
, while on iOS it isfalse
On Android the
retainUntilConsumed
is explicitly passed astrue
: https://github.com/ionic-team/capacitor/blob/master/android/capacitor/src/main/java/com/getcapacitor/plugin/App.java#L27On iOS the flag is not passed: https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/Plugins/App.swift#L48-L50
And therefore uses the default of
NO
as provided by thenotifyListeners
method seen here: https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/CAPPlugin.m#L91This means that if your client JS code adds a listener for
appStateChange
it will fire on first app boot on Android but not on iOS.Expected Behavior
Both platforms should behave the same. In our app we've found that we'd rather have the iOS behavior, which ensures the event doesn't fire on first app boot, only when the app resumes from the background.
Reproduction Steps
appStateChange
via the Capacitor App pluginSee that the console log statement appears on Android, but not iOS.
The text was updated successfully, but these errors were encountered: