Reputation: 2189
According to the react native firebase doc, the push notification does not work in simulator.
Even Out-of-app notifications (when app is in background and you see the notification in the status bar) does not work when you run the app on your real ios/Android device connected to your PC by cable. (In-app notifications work though using messaging().onMessage
)
Current behavior: My Firebase push notification works perfectly on both Android and ios in standalone apk/ipa. However, I cannot test it during development on simulator.
Desired behavior:
I want to receive push notification (Out-of-app notification) when the app is running on simulator in background, so that I can use messaging().onNotificationOpenedApp
method as usual.
Why I need this? Of course, each time I make a change regarding push notification, I can create a standalone app, install it on phone to see how it works. This approach has many issues:
console.log
, in general, no way to debug the code Upvotes: 8
Views: 6406
Reputation: 4546
For firebase's messaging().onNotificationOpenedApp
to be triggered I used the following payload json:
{
"Simulator Target Bundle": "bundle.identifier",
"google.c.a.e": 1,
"foo": "bar",
"aps": {
"alert": "Alert!",
"content-available": 1
},
"gcm.message_id": "0:1538488916770554%a88db343a88db34"
}
Upvotes: 4
Reputation: 1555
Finally, you can do this in Xcode 11.4 and later (Release note).
Simulator supports simulating remote push notifications, including background content fetch notifications.
Also here you can find a step-by-step guide to do that, based on react native.
Upvotes: 2