-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰] IOS - Background notification received as foreground notification too #7836
Comments
Also had the case of getting a white screen on ios. I guess is it because of HeadlessCheck function HeadlessCheck({ isHeadless }) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null;
}
return <App />;
}
AppRegistry.registerComponent(appName, () => HeadlessCheck); As a user, i open the app the same time the iOS launch it in background to run the |
馃 would be interesting to see all the handlers in play, also the JSON (or code that generates it) for the FCMs that trigger the problem - Note that in all cases I'm aware of, if an iOS app is not foreground and JSON has notification key, the firebase-ios-sdk library will post a notification. So you must not post your own in that case later or you will double notify. If you want to take control of behavior of notification posting for FCM with notification block while iOS app is in background you need to implement a notification extension helper, as documented in notifee repo |
I have the both handlers posted in the first comment. private Message getMessage(String token, String title, String text, Map<String, String> data, long ttl,
String sound, String channelId) {
Notification notification = null;
AndroidNotification androidNotification = null;
if (text != null || title != null) {
notification = Notification.builder().setBody(text).setTitle(title).build();
androidNotification = AndroidNotification.builder()
.setBody(text)
.setTitle(title)
.setSound(sound)
.setColor(COLOR)
.setIcon(ICON)
.setChannelId(channelId)
.setPriority(AndroidNotification.Priority.HIGH)
.build();
}
HashMap<String, String> apnsHeaders = new HashMap<>();
apnsHeaders.put("apns-expiration", String.valueOf(ZonedDateTime.now().plusSeconds(ttl).toEpochSecond()));
ApnsConfig apnsConfig = ApnsConfig.builder()
.setAps(Aps.builder()
.setContentAvailable(true)
.setSound(sound)
.setAlert(ApsAlert.builder().setTitle(title).setBody(text).build())
.build())
.putAllHeaders(apnsHeaders)
.build();
AndroidConfig androidConfig = AndroidConfig.builder()
.setTtl(ttl)
.setPriority(AndroidConfig.Priority.HIGH)
.setNotification(androidNotification)
.build();
if (data == null) {
data = new HashMap<>();
}
data.put("reload", "true");
return Message.builder()
.setNotification(notification)
.setToken(token)
.setAndroidConfig(androidConfig)
.setApnsConfig(apnsConfig)
.putAllData(data)
.build();
}
The idea is that I dont want to post it if the the firebase sdk already posted it. But in reality the firebase sdk post it and when the user opens the app the onMessage is triggered with the same notification and i have no idea how do i know that the firebase sdk didnt showed it already. I was expecting that ones it was posted its done with it but it seems that I get a race condition somehow (the notification is not discarded from some internal queue and it sends it to onMessage listeners) Edit: Not sure if it is important but we use 2 custom sounds. One is 1 second long and one is 27 seconds long |
Any news here - I have the same exact issue? |
Issue
We are encountering an issue where iOS users occasionally see twice the push notifications. First time the notification is displayed by the OS as we send a push notification with the
notification
key (not data only). The second time the notification is displayed using notifee but the problem is that we receive the same notification inmessaging().onMessage
after the app is opened.We have configured a setBackgroundMessageHandler. We send a push notification with firebase admin sdk from our backend. The notification has title, body and data, content_available is true.
We also have a listener for foreground push notification which looks like this:
Steps we use to reproduce (not consistently):
Remarks:
If you close the phone screen on step 1, the chance to reproduce it seems higher
Project Files
Javascript
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:AppDelegate.m
:Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:e.g. 5.4.3
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y/N
&VERSION
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: