0

I've been doing so much research, but it seems like all the articles out there are either sending notifications from the console or sending a push notification to a single device.

All I want is to send a push notification using Firebase ON my client and not on the Console to everyone. Do I need a server? If so, what information do I need to retrieve from it?

AL.
  • 36,815
  • 10
  • 142
  • 281
Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117
  • Did you see https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html? – Frank van Puffelen Mar 22 '17 at 19:21
  • @Frank van Puffelen that's using the deprecated API – Ali Bdeir Mar 22 '17 at 19:22
  • No API used in that blog post is deprecated as far as I know. Which part do you mean? For an even more up to date sample, see https://firebase.google.com/docs/functions/use-cases#notify_users_when_something_interesting_happens. But I updated the blog post to point there too. – Frank van Puffelen Mar 22 '17 at 19:24
  • And plus, that covers the sending of push notifications to a single device. – Ali Bdeir Mar 22 '17 at 19:24
  • To use the firebase new way and to send to a user segment, try [this](https://firebase.google.com/docs/notifications/android/console-audience). If you want to send to a topic, try [this](https://firebase.google.com/docs/notifications/android/console-topics) – Appafly Mar 22 '17 at 19:28

1 Answers1

2

If you simply want to send a downstream message, you don't really need a server. You can simply use Postman or cURL. Just specify the registration token(s)/topic you want to send your message payload to.

If you are aiming to send the downstream message from the client (Android app) itself, I would strongly advise not to. Quoting a portion of @FrankvanPuffelen's answer here:

Sending a message to devices (so-called downstream messages) requires a HTTP call that specifies the server key. As its name implies, this key should only be used in environments you can trust.

It is to avoid exposing the key to unauthorized users, preventing exploitation.

Graham
  • 7,431
  • 18
  • 59
  • 84
AL.
  • 36,815
  • 10
  • 142
  • 281
  • You can use for sending a message to devices (so-called downstream messages) HTTPS call that specifies the server key. – eurosecom Mar 23 '17 at 12:09
  • I won't worry about security, since this app won't be public. Can you provide me with the way? – Ali Bdeir Mar 24 '17 at 08:12
  • So just for practice? I guess you can look into this [post](http://stackoverflow.com/q/41560266/4625829) for reference. – AL. Mar 24 '17 at 09:30
  • Hi @AbAppletic If you think that my post contains the details that answered what you need, please do mark it as accepted, so that your question will be marked as *Already Answered*. Doing the same for your other posts would really help. Cheers! :) – AL. Mar 30 '17 at 03:51
  • @AbAppletic Of course i can. Watch my answer at http://stackoverflow.com/questions/37435750/how-to-send-device-to-device-messages-using-firebase-cloud-messaging/41913555#41913555 – eurosecom Mar 30 '17 at 14:59