Send Fcm Messages from Server Side to Android Device

is there anyway to send notification from one device to other device using FCM without Firebase Database?

Firebase Cloud Messaging does not support directly sending messages to a device. Sending a message to a device (known as a downstream message) requires that you specify the FCM server key, and (as its name implies) that key should only be used on a server, or otherwise trusted environment.

The reason for this is that having the FCM server key for a project allows you to send any message to any and all of the devices in that project, so having this available outside of a trusted environment would be a security concern.

But there is no need to use the Firebase Database to send FCM message. The simplest way to verify this is to send a message through a command line curl call, like shown here: How can I send a Firebase Cloud Messaging notification without use the Firebase Console? You can also implement the code to send a message in Cloud Functions or your own favorite server-side environment without a database. You'll just have to pass in the target of where to send the message into the function.

Send push notifications from server with FCM

How different is server-side coding?

Since there is not much difference, you can just check out most of the example server-side codes for GCM as well. Main difference with regards to GCM and FCM is that when using FCM, you can use the new features with it (as mentioned in this answer). FCM also has a Console where you can send the Message/Notification from, without having your own app server.

NOTE: Creating your own app server is up to you. Just stating that you can send a message/notification via the console.

The URL used is "https://android.googleapis.com/gcm/send". What would be the equivalent URL for FCM?

The equivalent URL for FCM is https://fcm.googleapis.com/fcm/send. You can check out the this doc for more details.

Cheers! :D

How to send FCM push notification message from app server to mobile clients?

I think in your situation, Firebase Console would be fine for sending notifications to both your iOS and Android application.
After configuring your application with firebase cloud messaging you are able to send notifications.

for your other doubt if any user download your application or update with the new build integrated with Firebase Cloud messaging, they will receive notifications.
FCM gives you option to send Single(via : device token for specific iPhone) or to all users who had downloaded the application with FCM integration.

so you don’t need to store any user data on your server !

for “How can you send notifications “ you can check these references : -

https://firebase.google.com/docs/cloud-messaging/ios/client - Google Firebase Docs

https://codentrick.com/firebase-cloud-messaging-ios/

https://www.youtube.com/watch?v=LBw5tuTvKd4 - swift

https://www.youtube.com/watch?v=JsWHzU1DxjM - Objective c

and with firebase you can integrate
Cloud Firestore,
ML Kit ,
Cloud Functions,
Authentications,
Analytics,
cloud storage,
Hosting,
Realtime database.

FCM messages not reaching device when sent from server

I was able to fix the issue. The format in which I was generating json, was wrong. I didnt put the payload under notification tag. Post that change it started working. Thanks a lot guys, for all your suggestions.

How to send device to device messages using Firebase Cloud Messaging?

UPDATE: It is now possible to use firebase cloud functions as the server for handling push notifications. Check out their documentation here

============

According to the docs you must implement a server for handling push notifications in device to device communication.

Before you can write client apps that use Firebase Cloud Messaging, you must have an app server that meets the following criteria:

...

You'll need to decide which FCM connection server protocol(s) you want to use to enable your app server to interact with FCM connection servers. Note that if you want to use upstream messaging from your client applications, you must use XMPP. For a more detailed discussion of this, see Choosing an FCM Connection Server Protocol.

If you only need to send basic notifications to your users from the server. You can use their serverless solution, Firebase Notifications.

See a comparison here between FCM and Firebase Notifications:
https://firebase.google.com/support/faq/#messaging-difference



Related Topics



Leave a reply



Submit