Repository navigation
馃敟馃悰馃敟 isHeadless iOS is buggy 馃敟馃悰馃敟聽#4163
Description
Issue
Describe your issue here
I used the isHeadless blocks of code from https://rnfirebase.io/messaging/usage#background-application-state to block the main App component being rendered on iOS when receiving a notification in KILLED state. So, it partly works. When a notification pops up on the screen, then I open it after few seconds (about 3 seconds) the App Component will render without a problem after opening the notification. But if I open the notification IMMEDIATELY the App Component will not render because the app gets opened at the same time it is returning null because of the isHeadless prop is true. So is there a way to fix this problem, or even better block Firebase from launching the app bundle on iOS when receiving notifications while app is KILLED (because anyway I use NotificationServiceExtension to handle iOS background/killed notifications so I do not need firebase for that).
Versions:
"@react-native-firebase/app": "^8.4.0",
"@react-native-firebase/messaging": "^7.8.1",
"react-native": "^0.63.2",
Project Files
Javascript
Click To Expand
package.json:
# N/Afirebase.json for react-native-firebase v6:
# N/AiOS
Click To Expand
ios/Podfile:
- I'm not using Pods
- I'm using Pods and my Podfile looks like:
# N/AAppDelegate.m:
// N/AAndroid
Click To Expand
Have you converted to AndroidX?
- my application is an AndroidX application?
- I am using
android/gradle.settingsjetifier=truefor Android compatibility? - I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
// N/Aandroid/app/build.gradle:
// N/Aandroid/settings.gradle:
// N/AMainApplication.java:
// N/AAndroidManifest.xml:
<!-- N/A -->Environment
Click To Expand
react-native info output:
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- iOS
- Android
- iOS but have not tested behavior on Android
- Android but have not tested behavior on iOS
- Both
react-native-firebaseversion you're using that has this issue:e.g. 5.4.3
Firebasemodule(s) you're using that has the issue:e.g. Instance ID
- Are you using
TypeScript?Y/N&VERSION
- 馃憠 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Activity
[-][馃悰] 馃敟馃悰馃敟 isHeadless iOS is buggy 馃敟馃悰馃敟[/-][+]馃敟馃悰馃敟 isHeadless iOS is buggy 馃敟馃悰馃敟[/+]mikehardy commentedon Aug 27, 2020
This is a complicated topic. If you've got a race condition (initially launched in background / no UI on a message, but then also tapped to bring to foreground) which condition is correct? It was headless. That's not wrong. It's not headless anymore, that's also true.
I think the answer will be different for everyone. Does your project have side effects when
<App/>is rendered? Can you eliminate those? Or only do them if https://reactnative.dev/docs/appstate says you are foreground?Why not be less fiddly in the native side on launch with iOS since iOS does not really have a headless state (vs Android) and use AppState instead? Maybe just with isHeadless as indicator it was a background launch, but without drastic app flow branches
OmarBasem commentedon Aug 28, 2020
@mikehardy I tried using AppState and few other techniques but nothing worked. Is there a way to stop firebase from launching the app while killed? Why is "didFinishLaunchingWithOptions" being called on the native side when receiving a notification while app is killed? I think this was not the behaviour in version 5.
OmarBasem commentedon Aug 28, 2020
So a temporary workaround is to avoid performing any network requests and other processing included in the componentDidMount method of the "HomeScreen" until app comes to foreground:
stale commentedon Oct 4, 2020
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
stale commentedon Nov 1, 2020
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.