Open psahgal opened 7 years ago
What is your payload sending for firebase endpoint? If you send both data and notification in payload, body will be ignored if you are in bakcground.
I don't think there really is a payload besides the message text. As I mentioned earlier, I'm just using the Notifications composer in the Firebase console. Here's what I have set up in the console:
I didn't put anything in the advanced options field.
Is this kind of notification intended to work with this library? I noticed that the Android code seems to look for the "custom_notification" field in the payload...do I need to put some JSON into this console under the "Advanced Options" section?
Android notification from FCM is very limited. The notification can only be delivered to notification tray. So you may well end up using custom_notification.
regarding your finding, com.evollu.react.fcm.ReceiveNotification
is not designed to be consumed by any Android service. It is just used to be send to Javascript world.
can you add breakpoint on onMessageReceived
and see if it is triggered when you send notification in foreground? context.sendOrderedBroadcast(message, null)
is where it should trigger JS callbacks
@evollu I am having the exact same issue and I confirmed that onMessageReceived
is indeed being triggered. The context is non-null and it calls context.sendOrderedBroadcast
. It works fine if the app is not running or if it is backgrounded.
@Elethier I found a workaround:
// This is triggered regardless of app state FCM.on(FCMEvent.Notification, async (notif) => { if (notif.fcm && notif.fcm.body) { // A new notification was received FCM.presentLocalNotification({ title: 'my title', body: notif.fcm.body, big_text: notif.fcm.body, show_in_foreground: true }) } })
well you can do that... why not use custom_notification?
@evollu it's just a proof-of-concept, my point is just that the workaround is to issue a local notification when a push is received.
yes. it is a workaround for android
@ericacooksey Thanks for the workaround, I think we'll end up using that if we decide to display local notifications. I guess I was a little confused about how much is handled by the library vs. what needs to be done in the project code. Just want to make sure I'm understanding this correctly:
custom_notification
property, this library will turn that into a local notification for me and display that to the user. (This is based on my interpretation of the project readme.)@evollu Is that the expected behavior? Because it seems rather unintuitive that "Hello World" isn't handled, but custom notifications are.
@Elethier you are right.
@Elethier - Could you pls post a sample code? I'm new to react native.
I don't get any output, even If I do like @ericacooksey described.
I've checked till RNFIRMessaging.presentLocalNotification(details); and found that the details-Object has data and this Function is fired in /node_modules/react-native-fcm/index.js.
Are there permissions needed to use presentLocalNotification ? I'm on Android 8.0
What woud be the way to send this Payload?
FCM.send( {payload-object-here} )
?
React Native Version: 0.47.2 Device: LG V20 (Model number LG-H990ds) Android Version: 7.0 App is running in the foreground
I'm testing out using Firebase Cloud Messaging with our React Native app and went through the setup instructions for this library on Android. I saw that the app receives notifications just fine while in the background, but in the foreground, the app doesn't receive any push notifications.
For testing, I set up a new project in the Firebase console and I'm using the Notifications Composer on the Firebase console to send push notifications. All I'm sending is a simple notification with "Hello world!" as the message, and it's not showing up in the notification tray when the app is in the foreground, even though I have the local notification publisher set up. I downloaded the example project and I also wasn't seeing a push notification when the app is in the foreground.
I have two questions:
Examples/simple-fcm-client/android/
)npm install
in the root folder of the example project (the folderExamples/simple-fcm-client
)npm start
in the root folder of the example projectI started debugging some of the code in the library and saw some obvious issues. For one, the intent in the
onMessageReceived
function within the classMessagingService
passes in an action named "com.evollu.react.fcm.ReceiveNotification", and there's nothing in the Android manifest listening for an action with that name. After correcting this naming issue and adding an intent filter in the Android manifest, I noticed that theSendNotificationTask
assumes the intent has some extras with properties such asbody
,title
, etc., but the intent has aRemoteMessage
object as its single extra under thedata
key.Please let me know if there's something wrong with my project setup that's causing the issue, otherwise I'm going to have to submit some major changes to the Android side of the code, and update the setup instructions.