1

I am building an app like Messenger, everything works normally like sending messages, receiving messages, video calling. the technologies i use are react-native, reactJS, socket.io, nodeJS, react-native-webrtc

I wonder how can when I close an app like the messenger I can still receive incoming call notifications from other people. I'm studying firebase notification and react-native-background-timer but it doesn't seem to work the way I want it to

Has anyone had a problem like this and have an answer, please let me know Have a nice day guys <3

Four
  • 125
  • 1
  • 1
  • 9
  • FCM (that you already mention) or [Web Push](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) is what these apps use. --- "it doesn't seem to work the way I want it to" No sure what you mean by that though, so it's hard to help. If you tried to implement these APIs, but can't get them to work, edit your question to show the [minimal complete/standalone code that any of us can run to reproduce where you got stuck](http://stackoverflow.com/help/mcve). – Frank van Puffelen Mar 29 '22 at 03:52
  • Hi @FrankvanPuffelen, "it doesn't seem to work the way I want it to" I mean when I close an app like the messenger I can still receive incoming call notifications from other people. because only when I open the app on my phone do I connect to socket.io and get other notifications and when i close the app the socket disconnect is automatically called – Four Mar 29 '22 at 03:58
  • Hi @FrankvanPuffelen , You mean FCM is firebase notification? – Four Mar 29 '22 at 04:02
  • 1
    Notifications systems like Web Push uses service workers, which are used to run background tasks and stay there even after you close the app. They are made this way so you can trigger some events without having the actual app displayed (like notifications, cron tasks, ...can't think of more examples). While this doesn't "fix" your problem, you can learn more about it here: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API – savageGoat Mar 29 '22 at 04:04
  • It's good to know more about this, I'll go check it out now, thanks @FrankvanPuffelen – Four Mar 29 '22 at 04:07

1 Answers1

3

In react native firebase there are two types of notifications "background" and "foreground".

Foreground Notifications:

A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a Notification. Foreground services continue running even when the user isn't interacting with the app.

When you use a foreground service, you must display a notification so that users are actively aware that the service is running. This notification cannot be dismissed unless the service is either stopped or removed from the foreground.

Background Notification:

A background service performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service.

You want to follow there Documentation to apply push notifications in react native.

Talha Akbar
  • 462
  • 3
  • 15