Appending message using FCM event
See original GitHub issueIssue Description
An error occurred when appending a message
Steps to Reproduce / Code Snippets
- Below codes works find when I use with local method, but when I put the code inside FCM event method ( FCM.on(FCMEvent.Notification, async (notif) => () ), it throws an error.
FCM.on(FCMEvent.Notification, async (notif) => {
if (this._mounted && notif.action === FCM.BACKEND_ACTION_MESSAGE) {
const { state } = this.props.navigation;
if (notif.chat_room_id === state.params.chatRoomId) {
let arrMsg = [];
let objMsg = {};
objMsg._id = notif.message_id;
objMsg.createdAt = new Date(notif.date);
objMsg.text = notif.message;
let objUsr = {};
objUsr._id = parseInt(notif.sender_contact_id);
objUsr.avatar = 'https://avatars0.githubusercontent.com/u/9919?v=4&s=40';
objMsg.user = objUsr;
arrMsg.push(objMsg);
this.stateMessages = GiftedChat.append(this.stateMessages, arrMsg); //### THIS THROWS AN ERROR
}
}
});
Error Msg
Invalid Date <unknown> .\node_modules\react-native-gifted-chat\src\MessageContainer.js: 44:38
PrepareMessages .\node_modules\react-native-gifted-chat\src\MessageContainer.js: 40:28
componentWillRecediveProps .\node_modules\react-native-gifted-chat\src\MessageContainer.js: 70:46
Additional Information
- React Native version: “react-native”: “^0.48.4”
- react-native-gifted-chat version: “react-native-gifted-chat”: “^0.2.7”
- FCM: “react-native-fcm”: “^9.6.2”
- Platform(s) (iOS, Android, or both?): BOTH
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Firebase Cloud Messaging
Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost.
Read more >Append messages to push notification - Firebase
Use a messages array to store all the incoming messages. If the user have clicked on the notification, you can use "Notification Click...
Read more >Web Push Notification with Firebase Cloud Messaging
Send and receive web push notifications with Firebase Cloud Messaging (FCM). This is a broad and shallow overview of the whole picture surrounding...
Read more >How to Push Notification in Android using Firebase Cloud ...
Since receiving FCM notifications require the use of the internet, add the following permission to the AndroidManifest.xml file anywhere between ...
Read more >Android Push Notifications (FCM) - IBM Cloud Docs
Create an Event Notifications service, add a push destination for Firebase Cloud Messaging (FCM), and send messages to Android devices. What is Event...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
latest version. when a try in debug mode works, but when a disable debug mode, i get this error “invalid date”
The gifted chat expects the Date object. So if you are not sending date object it will not work in debug mode. When debugging with chrome, chrome does some magic and makes it work.