0

This might be a duplicate questions, but still. I have seen many tutorials on sending notifications from Firebase Cloud Messaging to an android app, but I don't understand how to send notifications from my angular website to firebase, which will then push these notifications to android app. In all these tutorials, they have sent notifications by manually typing messages in the firebase UI.

My question how do I send notification data from my angular website to FCM, which will then send these notifications to my android app? Any references for this? Any procedure to follow?

Ridayesh
  • 61
  • 5
  • You'll need to send up your own custom API on a server, that you then call from the Angular code. That API receives and validates the message, and then calls the FCM API to deliver the message to the Android app. See my answer here and the blog post linked form it: https://stackoverflow.com/questions/37990140/how-to-send-one-to-one-message-using-firebase-messaging/37993724#37993724 – Frank van Puffelen Oct 23 '20 at 14:52

1 Answers1

0

In your case, you might consider having your own app server that will provide an API for your angular app to send notification. Here's a documentation on how you can send a notification to a device from your server.

https://firebase.google.com/docs/cloud-messaging/send-message

There are different parts of this implementation actually. First, your app server needs to provide an API to the Android app that will be used to send the firebase registration token from your app when the app is launched. You might consider storing those registration tokens in your backend database.

Then the other API that your server will provide, to send notification, can be integrated in your angular app. The server API should be able to find the exact registration token of the device where you need to send the notification and will call the API from FCM to send the notification to the device. Here's the API doc that you might consider taking a look into.

https://firebase.google.com/docs/cloud-messaging/http-server-ref

Here is a good tutorial that shows how you can implement the server side implementation to send the notification.

https://www.pluralsight.com/guides/push-notifications-with-firebase-cloud-messaging

Reaz Murshed
  • 21,071
  • 12
  • 69
  • 87