Perform POST to https://fcm.googleapis.com/fcm/send
Using headers:
Content-Type: application/json
Authorization: key={your-fcm-server-key}
Sending to specific topic:
Android:
{
"to": "/topics/test",
"data": {
"message": "hello world"
}
}
iOS:
{
"to" : "/topics/test",
"priority" : "high",
"notification" : {
"body" : "Hello world",
"title" : "FCM Message",
}
}
Sending push to specific devices:
Single device
Android:
{
"to": "{device-token}",
"data": {
"message": "hello world"
}
}
iOS:
{
"to" : "{device-token}",
"priority" : "high",
"notification" : {
"body" : "Hello world",
"title" : "FCM Message",
}
}
Multiple devices:
Android:
{
"data": {
"message": "hello world"
},
"registration_ids": ["{device-token}","{device2-token}"]
}
iOS:
{
"priority" : "high",
"notification" : {
"body" : "Hello world",
"title" : "FCM Message"
},
"registration_ids": ["{device-token}","{device2-token}"]
}
Sending push to topic based on conditions:
Android:
{
"data": {
"message": "hello world"
},
"priority": "high",
"condition": "'test' in topics"
}
{
"condition": "'dogs' in topics || 'cats' in topics",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!"
}
}
iOS:
{
"priority" : "high",
"notification" : {
"body" : "Hello world",
"title" : "FCM Message"
},
"condition": "'test' in topics"
}
{
"priority" : "high",
"notification" : {
"body" : "Hello world",
"title" : "FCM Message"
},
"condition": "'dogs' in topics || 'cats' in topics"
}
More information here: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
Import this collection: Firebase Postman Collection
Using FirebaseNet to send push notifications:
Task.Run(async() => {
FCMClient client = new FCMClient("YOUR_APP_SERVER_KEY"); //as derived from https://console.firebase.google.com/project/
var message = new Message()
{
To = "DEVICE_ID_OR_ANY_PARTICULAR_TOPIC", //topic example /topics/all
Data = new Dictionary<string, string>
{
Body = "Hello World",
Title = "MyApp",
}
};
var result = await client.SendMessageAsync(message);
return result;
});
Task.Run(async() => {
FCMClient client = new FCMClient("YOUR_APP_SERVER_KEY"); //as derived from https://console.firebase.google.com/project/
var message = new Message()
{
To = "DEVICE_ID_OR_ANY_PARTICULAR_TOPIC", //topic example /topics/all
Notification = new iOSNotification()
{
Body = "Hello World",
Title = "MyApp",
}
};
var result = await client.SendMessageAsync(message);
return result;
});
More information here: https://github.com/tiagomtotti/firebaseNet
<= Back to Table of Contents