-
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
Why setBackgroundMessageHandler not working in iOS also not able to get remoteMessage? #6241
Comments
Same problem, any update? thanks in advance. |
"@react-native-firebase/analytics": "7.6.9", setBackgroundMessageHandler doesn't get called either. |
Those old versions do not work correctly on new operating systems! They are years behind. Check the changelog for how to handle the breaking changes over the course of the previous major versions (it's usually small stuff, unless you need to use the new separate admob package) and get current. |
in my app, versions installed: "@react-native-firebase/app": "^14.5.1", and still not working |
Nit sure what to say. I've got an app that I send three data only FCM a day too. In the test backend version of the app it pops a notification so I can verify it works. It works Needs minimum complete reproduction |
@mikehardy @kildip I've got the same. The background message handler is never called. However, I do receive cloud messages in the foreground mode. The messages I send are only processed when I open the app. iOS 15.5
I tried to use both Firebase Console and a custom backend to send cloud messages. None of them worked for iOS. Android works fine with exactly the same code. UPDATE |
iOS mostly ignores data only messages, you can see log messages in console.app as the device received the message and doesn't deliver to app, that is by design from apple |
Hi I am also facing this issue. for me "onNotificationOpenedApp" gets triggered when I open app from notification (received in background) but same notification is not caught by "setBackgroundMessageHandler". please help, I am trying to execute some code when notification is received. P.S. setting content-available: 1 in apns payload is also not working and onMessage also doesn't called when it is 1, but on removing it foreground notifications are being caught at "onMessage". below is the payload for {
"message": {
"apns": {
"payload": {
"aps": {
"content-available": 1
}
},
"headers": {
"apns-priority": "5"
}
},
"token": <FCM Token>,
"data": {
"Nick": "Mario",
"Room": "PortugalVSDenmark",
"body": "test message",
"title": "test title"
},
"notification": {
"title": "Denmark vs Pune",
"body": "A match to watch this weekend"
}
}
|
Hi, I tried the following payload and it worked, I had to restart my device though, I think iOS was not delivering the notifications. also using the release config helps :) {
"message": {
"apns": {
"payload": {
"aps": {
"content-available": 1
},
"acme1": "bar",
"acme2": "42"
},
"headers": {
"apns-priority": "5"
}
},
"token": <FCM Token>,
"notification": {
"title": "Mumbai vs Pune finals",
"body": "Watch the match online now"
}
},
} |
This solved my issue. One question remains: why can messages from the Firebase Console reach my device, but messages from the backend can't? |
There is always the assertion that messages don't reach devices but in my experience messages reach the device, and data-only messages are judged by iOS power miser to be not worthy of delivery to your app. So your app is not booted. So people need to watch Xcode console on release version of app installed on real device and see what happens in the logs. Additionally any use cases based on data-only should be reconsidered if you need them to be reliable, because they will not be reliable. If you are including a notification block and it's still not delivered then you may need to check priority key in FCM JSON or similar. |
All updated to and my messeage is like:
with the code to send message:
But still not got setBackgroundMessageHandler fired. |
I solved it by this link. |
Yeah - that's a "mixed" message, has notification and data block. So firebase-ios-sdk posts the notification and our code / your code does not ever get control, so the handler won't be called. If the user interacts with it you'll see the handler for notification opening the app / initial notification called |
still not working in my project , any idea ? |
+1 |
anything about this? |
@mikehardy shouldn't this be added to the docs? Our app needs to have data-only notifications to be delivered reliably. The notifications are shown conditionally depending on other variables stored in the device. You mention you have an app that has data-only notifications that apparently are being delivered reliably. So what is the verdict here? Are data-only notifs supported? Should apps that need reliable data-only notifs write a swift Notification Service? I am just a bit confused between this thread vs. the docs related to Cloud Messaging here. Would the solution be a custom notification service written in swift? We are facing the issue where |
any update? |
1 similar comment
any update? |
Hello, so I was facing this issue, for the background state of the app, the notification was not playing the sound. Basically this prop 'apns' solved the issue
|
Hello. I was also facing this issue. Then I saw the last comment of @VaseaLuca. Now when I press on notifications received in the background. It stills calls index.js file:
});` `messaging().onMessage(async remoteMessage => {
}) ` With this, when I tap on notifications received in background, the I called this in useEffect in my Home screen because of my scenario:
In this way, I manage the interaction with background notifications + foreground notifications in iOS. |
Restarting the device did the trick. |
@zirho which device? computer or iPhone device? |
Hello @felixclack , @jeanregisser , @andymatuschak
I am using React native free-base version v10. 1 and React native firebase messaging version 14.9.1. I got the notification in the background but was not able to get logs(payload) in iOS. is there any solution for this
below the index.js file in I added the setbackgroundhandler.
`import messaging from '@react-native-firebase/messaging';
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log(remoteMessage);
})
AppRegistry.registerComponent(appName, () => App);`
I also enabled modes background fetch, remote notifications, background processing but get the remoteMessage in setbackgroundhandler and FCM also provided below body.
-"content_available": true, "priority": "high"
so please help me above issues
The text was updated successfully, but these errors were encountered: