In app messaging system react native and meteor

Hi guys,

I wish to implement a simple messaging system in my RN app.I have a collection called Messages which stores a message, a subject and a userID.I basically want to implement it with push notifications,the app should be available on android as well as IOS.

It should be working in such a way that when the admin writes a message adressed to that particular user, once the document is stored in the collection, the RN app gets it as a notification if it is running in the background or even in the foreground…as long as the user is logged in,and the app is running he will receive those notifications.

For those of you who have experience with React-native please do provide me wiht some guidance.


have you seen this?

I’m using Google’s free Firebase Cloud Messaging. It allows you to send unlimited messages to iOS and Android.

A meteor admin webapp sends the messages: On the client, a button click triggers a server method call, which runs a fcm-node functioncall, which sends the message.

On the react-native part, I use react-native-fcm to handle the incomming messages. Works when the app is in the foreground, in the background, and even when the app is not running and the devicescreen is locked.

Not the easiest thing to get going, though. Best way is to start sending messages from Firebase webclient, and try to get to receive the push notifications when the app is in the background. Then try to handle incoming messages when the app is reactived.

Sending the messages through fcm-node on the other hand is easy.

1 Like

I will look through this post…thanks.If that does the job it ll be
great.Ill get back to you if i need to find an alternative

I never used firebase before…thanks for the suggestion ill use it and try to figure out how to set it up for my use case.Thanks guys you are great

Ultimately, you are going to have to wrap some code that fetches new messages in tracker autorun and have that also work when the app is in the background mode.

Yeah…it seems so.Ill keep you posted in the days to come if i could implement it properly

what about react-native-push-notification?

No Idea. Haven’t used it. They seem pretty similar in possibilities and popularity.

I just picked one, and started from there.

Thanks man, i appreciate your advice and your detailed answer

what about a subscription from react-native-meteor?

react-native-meteor indeed already handles tracking changes in a collection on the server…i can set it up this way too but i dont know if that’ll work with the app in the background as for now once i navigate to home or another app on my android device, and i come back to the app it restarts and i have to login again through the root scene of my app.As it is quite a sensitive app the user shouldnt be connected to the server when the app is in background mode .I think a max of 15 minites since the app’s gone in background mode is enough for me to trigger a logout on the server…Dont know ow to do that yet.Spencer Carli’s One signal method or @eleventy 's suggested answer with FCM might help me out…

I also wish to know for the messaging system to work…i do not want my database to be overflown with messages…So how once the document is stored in the message collection and the push notification is sent to the client,once the user clicks the notification be it in the app or outside of it ,the document previously stored on the server is downloaded and stored within the app itself (maybe using AsyncStorage) and deleted on the server?All so that it will behave exactly like a sms messaging app?

Do you have ideas about how to achieve this?

Not exactly sure what you are trying to accomplish, but AFAIK, the only thing you can do with a push notification, is send a certain short( 2KB max or so) text message, which will pop up when the app is not running or in the background. You have no idea if the person has actually read it.

When the user clicks on the notification, your app opens up, and receives the same payload message on startup( a callback is triggered).

So you could send a notification "Hey, we’ve got some update: ‘4xd5ef’, and when the user clicks on the message, your app opens up, and triggers the download of '4xd5ef. Once the full document is received, the app signals the server that it is ok to delete serverside.

Ok.What i try to achieve is implementing a system that will mimic the way sms messaging works on the phones.You receive a notification (snippet) of the entire message while in the app is running or in background.As it is a messaging system id like for my server to not be overloaded with already sent data.Id like the RN client app to be able to persist those messages already downloaded from the server so that it only fetches new ones if there’s any…And of course a way to delete them…

Think of my side question as the way a typical android sms messaging app works.

Do you get it?

Well then they way I described should work: the push-notification has a double function:

  • Show a snippet of the full message
  • Trigger the user to open your app from the background or lockscreen.
    ( if the app is in the foreground, no notification will be shown, but it triggers an in-app callback so you can display a popup or alert).

Once the app is open( or was already open), the user is taken to the message-page, which downloads the complete message.

As soon as the message is downloaded, the app sends a signal ( Meteor method-call) to the meteor server to kill the message serverside.

OK i get it now.Thanks a lot