This question already has answers here:
How to send one to one message using Firebase Messaging
(5 answers)
How can I send a Firebase Cloud Messaging notification without use the Firebase Console?
(17 answers)
Closed 2 years ago.
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?
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
Related
This question already has answers here:
How to send one to one message using Firebase Messaging
(5 answers)
Closed 3 years ago.
I have build an android app to send the user to user notification using Firebase Cloud Messaging for that I have included FCM Server Key in client code.
Recently, I came to know about this that it is a security risk, that there could be malicious attack and the attacker can send the messages using that FCM server Key(if he comes to know about it). I am looking for the alternative for the same, can you guide me ?
I am using this tutorial Notification Tutorial
I agree that including the key in your client is a security risk!
One option you have is to send the notification via a cloud function. The cloud function would have the responsibility of all the interaction with FCM -- thus you keep the key secret. At the same time the function is able to do any necessary validation that the user is allowed to send the notification (e.g. authentication, rate limiting, formatting the message properly, etc).
Then have your app call the cloud function instead of trying to call FCM itself directly.
This question already has answers here:
How to send device to device messages using Firebase Cloud Messaging?
(14 answers)
Closed 4 years ago.
How do I send notification from an android device to another device through firebase cloud messaging?
I do not want to use the administrative panel of firebase for sending notifications, I just want to send from one device to the other.
FCM doesn't provide device to device communication, you will have to achieve through App Server or use FCM endpoint to send messages.
Do you have App Server implemented? which sends notification through FCM.
Approach 1:
If App Server is there then you can follow: https://firebase.google.com/docs/cloud-messaging/android/upstream and add logic in App Server to send notification.
Approach 2:
You could use Firebase Remote Config to share FCM server keys, and make Http request from android client.
This question already has answers here:
How to send Device to device notification by using FCM without using XMPP or any other script.?
(3 answers)
Closed 5 years ago.
Is there a way to send push notification between 2 android devices without a server?
I found some tutorials but all of them was using the node.js for sending a notification. (Or I found that some samples that were using the firebase console for doing this)
Nope,
You need a "server" to do push notification. You can use a variety of services to do that, as you mentioned firebase is one of them. You may not need a full on server, but you need some kind of service to do that, you can't simply send notifications between devices straight away:
Some examples are:
AWS Serverless functions
Cloud functions in firebase
If you'd rather use one of these services, then you'll need to configure FCM in your app, you can check how to do that in the docs. And some nice sample codes here :)
This question already has answers here:
How to make a chat application in android? [closed]
(6 answers)
Closed 9 years ago.
I am developing an Android app in which I have to implement chat messaging. I would like one to one chat or a group chat.
But I have no idea how to start. Please help me with this stuff. Any help will be appreciated.
A simple chat mechanism will have 2 basic functionalities
Send the message to server (with info about the recipient)
Receive the message from server (designated for my user name)
First step is simple, we can create a web service which will accept the message with additional information about recipient(s). We can create it using any server side language.
Step 2, that is fetching the message from server can be done using 2 techniques, Pull the message (using polling) from server, or Push the message from server to android phone
Polling: In this, the android device will keep accessing server after a few seconds to check if there is a message available for user. This again can be implemented using a simple async task at the client side which will keep calling a web service after say 2-3 seconds. This is fine to use if we are planning to enable chatting only when user is accessing the app (no notifications like gmail or facebook), so that we can kill the polling service when not in use (otherwise it will eat up resources).
Push notifications: a better option is to use push notifications. Android provide Google cloud messaging or GCM (http://developer.android.com/google/gcm/index.html) which will help achieve push from server easily. Otherwise you can try a third party API like urbanairship or pushwoosh depending on your requirement. Push notifications will help the user to receive messages even when he is not using the app.
So in nutshell, a webservice to receive the messages and a push notification mechanism should be sufficient to implement a chat service in android.
Little bit about UrbanAirship
I used UA in one of my projects for push notifications as I needed to support both iOS and Android. If you just want to support Android GCM might also be a good option.
Coming back to UA, check this for sample code and usage: https://docs.urbanairship.com/display/DOCS/Home
The way it works is simple, when someone installs the app and is connected to internet, app registers itself to the UA service. A unique code is specified for each installed app (this is the time when you can capture the user name and unique code and store somewhere in your DB). Next UA provides an API using which you can push a message to designated recipient(s), using the unique codes which are available with UA. These messages can be received by android app and used as per the requirement. Even if the app is not running we can show a notification just like when we receive an email or a message
You can use an existing platform like Scringo. It gives you a one-on-one chat as well as group chat (both the client and the server) as well as the push notification service.
This question already has answers here:
Push Notifications in Android Platform
(20 answers)
Closed 9 years ago.
I have a website which supports Push-notifications, but what i must do to receive thhis notifications in my app?
You could use Googles Android Cloud to Device Messaging. This also C2DM called funcionality enables you to push short messages to Android Devices. These short messages typically do not contain the actual data but only a code for "there is something available". In a next step, your application pulls the actual data from your server.
You can find a lot of usefull information by searching for c2dm here on StackOverflow. Also see this very usefull tutorial.
For implementng Push-notifications in your app you need to use Cloud to Device messaging or short C2DM
here some tutorial for implementing C2DM in Application:
Android Cloud to Device Messaging (C2DM) - Tutorial
Android Cloud To Device Messaging
For Push Notifications You need a sever side, that will manage your push subscriptions and send pushes to your user base.
Look at Simple guide how to integrate Android Push Notifications, it's easy to integrate Push Notifications into your app using this guide, just add some lines of code.