-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛] setBackgroundMessageHandler does not work on IOS > 17 and react native 72.2 #7548
Comments
Hi, could you solve the problem? @alexstock1 |
If you include a notification block and a data block it is considered a "mixed" content message the message will not trigger a background handler ever as it will instead (at the deeper firebase-ios-sdk layer) trigger a user-visible notification (but not start your app! no handlers called!). If the user interacts with the message it will open your app and trigger onNotificationOpened with message contents that include the data block I believe our documentation here may not be accurate and it conflicts slightly with upstream 🤔 - it would require some testing to see. The difficulty with testing is that there are a lot of conditions to meet in order for the test to be accurate
Upstream docs state this, which makes me think the behavior you observe is by design:
|
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 attention?
Thank you for your contributions. |
I am also facing this issue. |
Generating Remote notification Apple Docs {
"message": {
"topic": "my-tpoic", // or token
// Shouldn't contain notification block, as it is data only message
"data": {
"title": "Background notification 1",
"body": "Background Notification 1",
},
"android": {
"priority": "high"
},
"apns": {
"headers": {
// apns-priority should be 5 when apns-push-type is background
"apns-priority": "5",
"apns-push-type": "background"
},
"payload": {
// To send a background notification, create a remote notification with an aps dictionary that includes only the content-available key
"aps": {
// The background notification flag
"content-available":1
}
}
}
}
}
You can test this using Rest API or Google OAuth Playground If you would like to test this using OAuth Playground then
{
"message": {
"topic": "topic-name-or-token",
"data": {
"title": "Background notification 1",
"body": "Background Notification 1",
},
"android": {
"priority": "high"
},
"apns": {
"headers": {
"apns-priority": "5",
"apns-push-type": "background"
},
"payload": {
"aps": {
"content-available":1
}
}
}
}
} As this is a background message and won't show any notification alert. If you would like to show an alert you can use notifee messaging().setBackgroundMessageHandler(async remoteMessage => {
// Update local storage
// And Display notification if necessary
return notifee.displayNotification({
title: remoteMessage.data.title,
body: remoteMessage.data.body,
data: remoteMessage.data,
android: {
channelId: 'channel_id',
smallIcon: 'ic_notification',
color: '#000060',
},
});
}); Hello @mikehardy, Do you think this is the correct way to show notification alert for background notifications? In my app I have a requirement to show notification count and notification alert. Adding a Also, I don't think its reliable to depend on I was thinking of sending two different notification to solve this issue.
But sending two different notification for a single thing doesn't sound good either. Please let me know your thoughts. |
@rawatnaresh I think this is a fine way to go about it for android only, on iOS the delivery of data-only messages is unreliable and you must not count on it for your features. I would use this for your android device tokens or topics android is subscribed too For iOS you want to send a notification block as it is the only way to guarantee delivery. You will need to use a notification extension helper if you want side-effects besides just showing the notification and you'll need to be very careful to have rapid execution so you fit in the small execution timeslice iOS will give you on the way to posting the user-visible notification |
Thanks for the suggestion. I'll look into Notification Extension helper |
Hi, Can anyone help me to solve this issue #7715 |
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 attention?
Thank you for your contributions. |
Hey @alexstock1 did you manage to fix this ? My payload is look like yours but |
@alexstock1 @mikehardy , Iam facing the same issue please look into this |
Why my notification only play in foreground but play default notification sound in background ? if (isGmsProvider(provider)) {
} |
@mikehardy do you know why this would be happening? thanks for your time |
Hi all,
after the update to react 0.72.2 and react native firebase 18.5.0,
(I have made everything that was written in the instructions and checked everything a couple of times, and i use
use_frameworks! :linkage => :static
)setBackgroundMessageHandler
does not work on IOS > 17 at all when the app is minimized (Background mode), on Android everything works as expectedbelow you can find the requested body
The text was updated successfully, but these errors were encountered: