How to efficiently send personalized notification to 10k users using FCM - push-notification

FCM gives two options to send notifications:
[to] - takes one gcm token
[registration_ids] - takes array of 1000 gcm token
So, If I had to send message to 10k users then using registration_ids it will take 10 request to fcm server. But the message is same for every request. I can change message every time in case of to but then i will have to send 10k different requests.
Now, I want to send personalized message.
eg: registration_ids[0]='ggggss' his name is alpha. I would want to send hey alpha,.... similarly for every user.
Is there a way to send personalized notification efficiently?
example syntax: curl -X POST --header "Authorization: key=" \
--Header "Content-Type: application/json" \
https://fcm.googleapis.com/fcm/send \
-d "{\"to\":\"\",\"notification\":{\"body\":\"Yellow\"},\"priority\":10}"

There is no built-in mail merge functionality in Firebase Cloud Message (as far as I know). You will either have to send the same message to multiple users, or perform a separate API call for each user

Related

OAUTH token for firebase cloud storage?

I am trying to upload an image to my cloud storage on firebase on an application where I won't have access to googles client libraries. From my understanding, I've followed this documentation on uploading images:
curl -X POST --data-binary #OBJECT_LOCATION
-H "Authorization: Bearer OAUTH2_TOKEN"
-H "Content-Type: OBJECT_CONTENT_TYPE"
"https://storage.googleapis.com/upload/storage/v1/b/BUCKET_NAME/o?uploadType=media&name=OBJECT_NAME"
Specifically, on postman I added the file location, the OAUTH_TOKEN I believe I used was from this location:
enter image description here
However, I've run into an unauthorization error, but I did change my rules on firebase cloud to allow anyone to read/write just for testing. However just to clarify, I can use the bucketname on my cloud storage as well correct? I guess the problem must lie in not having the right OAUTH token which I am still confused on how to generate. any help is greatly appreciated.

How can i secure my Firebase "subscribe to topic" from the web client?

In firebase FCM i can subscribe to a topic through the web client like this:
curl -X POST -H "Authorization: key=<your_server_key>" -H "Content-Type: application/json" -H "Content-Length: 0" "https://iid.googleapis.com/iid/v1/<your_instance_token>/rel/topics/<topic_name>"
The only usage i have form Firebase is sending push notifications form the server to web clients that are subscribed to a specific topic.
But how can i prevent unwanted people from subscribing to my topics?
FCM topics are not "secure". Anyone can subscribe to them. You should not distribute sensitive data over a topic.
If you want to send sensitive data to only certain users, you should be using device tokens to send messages directly. Either that, or accept the fact that any client can "listen in" on the topic, if they just know the name of the topic and the configuration of your project (which is essentially public since it gets baked in your app at build time).

how to upload an image to the firebase with specific user only in reactnative?

I'm building an app as my homework and stuck in a problem i am not understnding that how to add image of a specific user and then display after login?
You can use Google Cloud Storage to upload your images from mobile device or backend.
You would need to signup for Google Cloud Console for this.
if you want to directly upload from device, you can use REST API like this:
curl -X POST --data-binary #[OBJECT_LOCATION] \
-H "Authorization: Bearer [OAUTH2_TOKEN]" \
-H "Content-Type: [OBJECT_CONTENT_TYPE]" \
"https://www.googleapis.com.com/upload/storage/v1/b/[BUCKET_NAME]/o?uploadType=media&name=[OBJECT_NAME]"
mentioned here

How can I send a Telegram message using curl from my own Telegram account (not from a bot)

I want to send a message to a group from Telegram user. The message should send from my personal account instead of the bot.
Is it possible, and if so what is the API method? I want to use CURL.
Vesa
You can't do it via HTTP request, if you want to send messages from a human account, try unofficial telegram-cli instead.

Messaging using Firebase do not behave like Firebase console

I can succesfully send a post request from my server at home to the Firebase server. The message is delivered to the client without a problem.
Except that the app must be either running or in the background.
If the app is closed the message goes to limbo. There is nothing in the system tray, there is no sound, nothing.
Is this the expected behavior?
This is the curl command I am using:
curl -X POST --header "Authorization: key=AIzaSyBntseBqux9nBX8y" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"fxhL9uQBYUo:APA91bGaEWqTJ2mde1vSlfOZWHYrYTQLbZdFih2hs_wszaxPsthfMN5lnxH6RHquUImmT\",\"data\":{\"action\":\"run\"}}"
Am I missing some extra fields that make the device act like it is doing now?
PS: Server Key and Token are not real.
Your code is sending a data message, the Firebase Notifications console sends notifications messages.
One big difference between these two types of messages is that notification messages are automatically shown in the system notification area if your app is not in the foreground.
See this page in the Firebase documentation explaining the difference between these message types.

Resources