0

I am coding a React Native app and I using Firebase push notification service.

In my app, users can send message for each other and I want to notify them when they get message.

I found one way for native android I can code for react native it is not problem just I want to know if there is better way. I can make post to directly to Firebase service with using Http post.

This is the link which way I found: https://blog.usejournal.com/send-device-to-device-push-notifications-without-server-side-code-238611c143

I want to push notification to specific device without server, is there another way to do this?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

Sending a message to a device with Firebase Cloud Messaging requires that you specify the FCM server key. As its name implies, this key is supposed to only be used in trusted environments, as knowing it allows one to send any message they want to all users of the app. For this reason it is not possible to secure send messages directly from one device to another device with FCM.

Instead you will have to run code in a trusted environment, such as your development machine, a server you control, or Cloud Functions. Your client-side application code invokes the server-side code, that ensures the call is authorized, and then calls the FCM API.

For more on this see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807