I am trying to send image in push notification from firebase console but it doesn't work, so i tried to send from the postman but it doesn't work either. I tried other parameters like icon, image, media_url, mediaImgUrl..etc from Internet in the body.
Help me out here so that i can send image in notification.
{
"to": "tokennnnnnnnnnnn............",
"content_available": true,
"mutable_content": true,
"data":
{
"message": "Hey!",
"icon": ".....farm.png"
},
"notification":
{
"body": "Topic",
"sound": "default",
"icon": ".....farm.png"
}
}
Try sending image with this payload :
{
"message":{
"token" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"android": {
"notification": {
"body" : "This is an FCM notification that displays an image.!",
"title" : "FCM Notification",
"image": "url-to-image"
}
}
}
Related
This is how I am sending a FCM notification to my Android device through Postman.
{
"to": "<fcm_token>",
"notification": {
"title": "Title",
"body": "Body",
"tag": "bar"
},
"android":{
"notification": {
"tag": "foo"
}
}
}
But the tag neither works in notification.tag nor in android.notification.tag part. I keep seeing old notifications, they are not dismissed (overwritten by new one).
What am I doing wrong?
I have integrated pubnub API in one of my project. I am trying to get bundle of data that i have sent in payload. I have added FCM for push notification. I am getting push notification in all cases but not getting bundle data when app is killed or in background. Already getting payload object when app is in foreground but not getting any data when app is in background or killed.
Payload 1 :
{
"pn_gcm": {
"notification": {
"title": "Barack Obama",
"body": "12",
"channelName": "Hell 4_656"
}
},
"firstName": "Barack",
"lastName": "Obama",
"displayName": "Barack Obama",
"profileImageUrl": "abcURL",
"userId": "173",
"type": "sender",
"time": "1615958943297",
"message": "12"
}
PayLoad 2 :
{
pn_gcm={
notification={
title=BarackObama,
body=Hello,
image=Hell4_656
}
},
firstName=Barack,
lastName=Obama,
displayName=BarackObama,
time=1615958740553,
type=sender,
message=Hello,
profileImageUrl=abcURL,
userId=173
}
I am getting notification object when app is in foreground but not getting any of them when app is in background or killed.(Getting some FCM default object)
I am trying to get notification object in bundle when launch app from Notification tray
Answer
Made JSON payload like this :
{
"pn_gcm": {
"notification": {
"title": "Barack Obama",
"body": "18"
},
"body": {
"channelName": "Hell 5_657",
"firstName": "Barack",
"lastName": "Obama",
"displayName": "Barack Obama",
"profileImageUrl":
"http://3.137.127.137/quiqle/uploads/profile/1615523786_4866.jpg",
"userId": "173",
"type": "sender",
"time": "1615965488916",
"message": "18"
}
}
}
You need to add data with information which you want to receive with push into pn_gcm.
Information outside of pn_(gcm|apns) (including tjpse) will be delivered as regular messages
Message can be as follows:
using notification:
{
"pn_gcm":{
"notification":{
"title":"Chat invitation",
"body":"John invited you to chat",
"sound":"default"
}
}
}
Or using data:
{
"pn_gcm" : {
"data" : {
"room" : "Portugal vs Denmark",
"body" : "great match!"
}
}
}
or both:
{
"pn_gcm" : {
"notification": {
"title":"Portugal vs Denmark",
"body":"great match!"
},
"data" : {
"room" : "Portugal vs Denmark",
"body" : "great match!"
}
}
}
For an explanation on the different between data and notification, please read the official FCM docs, About FCM messages.
See also:
Why are my FCM push notifications not working?
I am sending a push token to a specific device via the FCM API on testing with Postman, but I intend to send them from the server.
{
"to" : "my_device_token",
"notification" : {
"notificationTitle" :"test from server",
"notificationBody" :"test lorem ipsum"
}
}
I am receiving the response
{
"multicast_id": 4996861050764876123,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results":
[
{
"message_id": "0:1519567530487886%f95ee7d4f95ee123"
}
]
}
Which shows no error, however I don't get any notifications on my phone.
I tried the same device token using on firebase website "Notifications => New Message => Single Device", and it works.
I see threads about not receiving the notifications when the app is not running, however I don't get any even if the app is running.
Edit: My application is built using Xamarin.Android, if relevant.
The notification property keys are title and body:
{
"to" : "my_device_token",
"notification" : {
"title" :"test from server",
"body" :"test lorem ipsum"
}
}
See Table 2b in the documentation.
I am sending push in a single devices using via FCM api. The JSON is given below.
In the case of Android
{
"to" : "device Tokens", // Your android device token
"data" :
{
"body" : "test",
"title" : "test",
"pushtype" : "events",
};
In the case of IOS json
{
"to" : "device Tokens", // iphone tokens
"data" :
{
"body" : "test",
"title" : "test",
"pushtype" :"events",
},
"notification" : {
"body" : "test",
"content_available" : true,
"priority" "high",
"title" = "C#"
}
} ;
put in index.js
PushNotification.configure({
onNotification: function (notification) {
console.log("NOTIFICATION:", notification);
},
requestPermissions: Platform.OS === 'ios'
})
in your screen
createChannels =()=>{
PushNotification.createChannel(
{
channelId:"test-channel",
channelName:"Test-channel"
}
)
}
handleNotification=()=>{
PushNotification.localNotification({
channelId:"test-channel",
title:"Kinza ",
message: "hi gow adww biy",
});
PushNotification.localNotificationSchedule({
channelId: "test-channel",
title:"Alram",
message:"Hi how are you",
date: new Date(Date.now() + 20*1000),
allowWhileIdle:'true',
});
}
I have a Cordova app, using the push plugin.
On the server I am sending the GCM messages with node-gcm.
I receive notifications just fine, for iOS and Android, and they open the app when clicked, however on Android the 'notification' event does not fire.
push.on('notification', function(data) {
console.log(data);
alert('got PUSH!');
});
If the app is running in the foreground then I get the 'got PUSH!' alert, but when the app is in the background and I click the push notification when it arrives, it opens the app but does not alert 'got PUSH!'.
How can I get the 'notification' event to fire after the app opens?
Here is the gcm Message I am sending to the device:
{
"params": {
"notification": {
"title": "SO post demo",
"body": "THIS IS A TEST!",
"icon": "ic_launcher",
"sound": true
}
}
}
I believe that I need to have something in the notification payload to solve this, but nothing I have tried gets that event to fire when the app opens from the background.
Here are a couple of things that I have tried:
Using "content-available" (as suggested here), using message.addData:
{
"params": {
"notification": {
"title": "SO post demo",
"body": "THIS IS A TEST!",
"icon": "ic_launcher",
"sound": true
},
"data": {
"info": "super secret info",
"content-available": "1"
}
}
}
Same again, but putting my params in the json I use to make the Message:
{
"params": {
"notification": {
"title": "SO post demo",
"body": "THIS IS A TEST!",
"icon": "ic_launcher",
"sound": true,
"info": "super secret info",
"content-available": "1"
}
}
}
In methodically creating this question I found the answer.
I needed my payload to look like this:
{
"params": {
"data": {
"title": "SO post demo",
"body": "THIS IS A TEST!",
"icon": "ic_launcher",
"sound": true
}
}
}
This messes up the notification icon that displays (it is a zoomed in version) but, at this stage, I can live with that.
I am using GCM to send push messages to multiple users, but even though I am getting success and message IDs in the response, I cannot debug them in FCM diagnostics and they don't arrive to the devices.
How can I debug this?
The message I'm sending:
{
"priority": "normal",
"time_to_live": 6000,
"delay_while_idle": true,
"content_available": true,
"notification": {
"title": "Title",
"text": "Text",
},
"data": {
"title": "Title",
"text": "Text",
},
"registration_ids": ["ID1", "ID2"]
}
The response is an array of message IDs.