-
Notifications
You must be signed in to change notification settings - Fork 125
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
Sending Custom Data in FCM not working #212
Comments
Same issue here... |
seems to be a problem with expo, doesn't it ? |
Hey guys. Let us know if you can confirm that this is an issue with expo. |
i experienced the same problem. i am not using Expo just nativescript for my app. The problem seems to be due to the migration of the new http api of FCM. my problem was that after migration it seems the data-only notification was not send anymore. Also the android_channel_id property is now just channel_id (although i am currently not using it anymore thus you will not find it in the code below) anyhow, this is working for me now: const data = {
collapseKey: Math.random().toString().replace('0.', ''),
title: 'test',
topic: 'all',
body: 'text',
priority: 'high',
custom: {
id:'123',
},
fcm_notification: {
},
icon: 'notification_icon',
sound: 'test.wav',
category: 'alarm',
truncateAtWordEnd: true,
pushType: 'alert',
};
const pushResult = await push.send(result.user.fcmToken, data); strangely i need to put the empty fcm_notification object into it, because otherwise https://github.com/appfeel/node-pushnotifications/blob/master/src/utils/tools.js#L77 will create these properties for a notification message it seems and then my custom messaging service is not invoked on the android client side. Really strange, but this was doing the trick for me. hopefully this also helps others |
@eikaramba Thank you for the insight. Can you let me know what exactly the |
@alex-friedl i don't use gcm, i use fcm. you should switch too i guess. i don't have any more code than what i shared above. |
I don't use anything myself anymore, I just try to maintain this is good as I can without having a working notification setup for real life testing 😬 |
sry i thought you are using it as a library, my bad. Unfortunately i don't have access to prod environment anymore where i did use that code. but yeah i think the biggest problem was that https://github.com/appfeel/node-pushnotifications/blob/master/src/utils/tools.js#L77 is overriding the config if fcm_notification is not passed. and altough it says "buildGcmNotification" it is also used for fcm notifications. The only more code that i have is:
rest is as above. So maybe it is specific to fcm, which should be used anyway as gcm is deprecated. |
Sending custom data with FCM is not working. When trying to log the notification received in Expo React Native, no custom data is received.
Here's the code:
The notification is received but the custom param "name" is not there.
The text was updated successfully, but these errors were encountered: