0

So I have registration/login handled on my side using Laravel. I tried adding React-native-firebase so after login I could subscribe to topic like notifications/:userId so I would get notifications only for that user as currently every user is getting push notifications.

I can't find any guide on how to make this so it will work when app is in "dead" state or minimized.

I'd appreciate any help. Thanks

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mil
  • 113
  • 1
  • 11

3 Answers3

0

You can use the below mentioned library for firebase integration.

https://rnfirebase.io/

0

Firebase has the Firebase Cloud Messenger, which has some notification control and badges from notifications built into it. I hope that helps, here is a link React-Native (https://rnfirebase.io/docs/v3.1.x/messaging/reference/messaging) and Firebase Docs (https://firebase.google.com/docs/reference/js/firebase.messaging)

Jacob
  • 586
  • 6
  • 27
0

You have generate fcmtoken after user log in, and save it to database.

After that from server side you have to fetch the fcmtoken for that particular user and call firebase pushnotification api / service.

Notification Payload :

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "title":"Portugal vs. Denmark",
      "body":"great match!"
    },
    "data" : {
      "Nick" : "Mario",
      "Room" : "PortugalVSDenmark"
    }
  }
}

If you want to send message/notification to multiple devices minor change is

tokens: ["token1", "token2"]
Vinit Bhavsar
  • 226
  • 3
  • 13
  • I recommend to use v5 because in v6 lib, notification badge count update is removed. Still you can manage from server side to update notification badge count. – Vinit Bhavsar Nov 05 '20 at 16:39