FCM API returns a success response but push notification is not delivered to user - react-native

I am sending push notification using FCM legacy API and by request looks like the following
POST https://fcm.googleapis.com/fcm/send
{
"to" : "USER-DEVICE-TOKEN",
"collapse_key" : "type_a",
"priority" : "high",
"notification" : {
"body" : "Getting this?",
"title": "Let me know if you got this message",
"icon": "ic_launcher"
},
"data": {
"one": "two"
}
}
This request returns the following response
{
"multicast_id": 144107415xxxxxxxxx,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1581xxxxx5%32xxxxxxxxx"
}
]
}
But the user never receives any push notification. This happens for most of the user but about 10% of total user does receive push notification send by the same mechanism. I am out of sorts regarding this, I don't know whats going on or even how to go about debugging this. Has anyone run into this issue? The app is written in React Native and uses invertase/react-native-firebase for firebase features. Thanks

Related

Format of the address is invalid in IdeaMart Subscription API

I want to subscribe to users to my Ideamart mobile app. This is the sample request I sent to the ideamart API
{
"applicationId": "APP_01234",
"password": "xxxxx",
"action": "1",
"subscriberId": "tel:94761234567"
}
This is the response I got
{
"statusDetail": "Format of the address is invalid.",
"version": "1.0",
"statusCode": "E1325"
}
How should I fix this issue?
This error occurred because the user was not subscribed the application. User must subscribe it first to use the CAAS api.
try after recharging(reload) your mobile account

Firebase Cloud Messaging Reports - not displaying sent count in Reports

We have set "analytics_label" in the message as stated in the documentation and the message is getting delivered as well. But we do not see any entry in the report. Please check our message string and let us know what might be wrong. Appreciate your help.
REST API being called
https://fcm.googleapis.com/fcm/send
Message being sent
{"topic":"81xxxxx42","android":{"priority":"high"},"priority":"high","fcm_options":{"analytics_label":"nwy81xxxxx42"},"data":{"MID":-1,"frm":"99xxxxx32","MTP":9,"msg":""}}
I'm not certain what library you're using or if you're just POSTing directly to the REST API, but looking at code that I know works I think you just need to make fcm_options and analytics_label camel case.
{
"topic": "81xxxxx42",
"android": {
"priority": "high"
},
"priority": "high",
"fcmOptions": {
"analyticsLabel": "nwy81xxxxx42"
},
"data": {
"MID": -1,
"frm": "99xxxxx32",
"MTP": 9,
"msg": ""
}
}

how to fix 'InvalidRegistration' FCM

I'm getting the InvalidRegistration error in response of my post request for sending push notification.
When I use the Firebase console to send push notification it works all fine.
so I copy the exact registration token I've used in console. I also get my api-key from my project-settings/cloud-messaging.
for sending the post request I've used postman.
I've sent my post request to https://fcm.googleapis.com/fcm/send
my postman header has this attributes:
key: Authorization value: key=<api-key-i-got-from-console>
key: Content-Type value: application/json
my body is:
{
"to" : "fDj8iG5ajZI:APA91bHfs_AjdxOc5Qn-1Plr_OfitrdCTchb4syhPGC0DhPMGiWggJ9mQ5W00ombqowlUSCUOfH_0N3KA-KF0VjQvj5mcMNUMUBgTblpsNzra60kwrbtH2ikfdBa8lenh__olBpGZD4O'",
"collapse_key" : "type_a",
"notification" : {
"body" : "plz work",
"title": "title"
},
}
I get this response from the Firebase
{
"multicast_id": 5801302802423881516,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidRegistration"
}
]
}
I did the same with fcm and django-push-notification and got the same result I have no clue what am I doing wrong since my token works with the console and I can send push notifications from the console.
it was my bad that I had an extra ' in the end of my token...

Firebase Cloud Messaging topic send, message does not show in Notifications and is never sent

I am using the REST api and I am trying to send to a topic. I know the topic exists because I can see in the Notification console that the topic is there. And I can send a test message through the console and that works.
However, when I use the REST api, I get an http status 200 response with json {"message_id":8769790390495267408} which looks like a successful send. However, the message does not show up in Notifications and the message is not sent to subscribed clients.
My message looks like, which is from the docs
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
And I am using the "Server key" and not the Web api key.
Thanks for any help.
For iOS, try using notification instead of data. Then add in the priority and set it to high. The payload should look something like this:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"priority": "high",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}

Unnable to make Google Cloud Messaging Work

I followed the new tutorial Implementing GCM Client on Android, and I'm unnable to make it work.
I get the token form my device succesfully, and when I send the following message
{
"to": "f19jCbaw-S4:APA91b....",
"notification": {
"body": "body",
"title": "title"
},
"data": {
"message": "test"
}
}
to https://gcm-http.googleapis.com/gcm/send, I get the result:
{
"multicast_id": 844556567...,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1433092445706613%..."
}
]
}
But my app is never entering into the the onMessageReceived of MyGcmListenerService class. The only clue that I have is the following log trace:
6399-6454/com.miapp.app W/GcmNotification﹕ Failed to show notification: Missing icon
I'm duplicated step by step the Google Cloud Messaging Quickstart sample project. Obviusly I use my api key and my sender id... but id does not work, my app never stops in my onMessageReceived method.
Anybody else is having this problem?
In fact the payload without notification should reach the "onMessageReceived" method and work fine, but if the notification is present into the payload, the same error is displayed "Failed to show notification: Missing icon".
I tried to set the icon inside the AndroidManifest.xml (on the both intent-filter, on the receiver), but nothing worked.
If you do not require notification, just remove them from the payload.
And if you need the notification, you need to add another required field inside the notification:
If your icon is inside the mipmap you can add:
"icon" : "ic_launcher"
if your icon is inside the drawable, you should have:
"icon" : "#drawable/ic_myicon"
So your new request would look like:
{
"to": "f19jCbaw-S4:APA91b....",
"notification": {
"body": "body",
"title": "title",
"icon" : "#drawable/ic_myicon"
},
"data": {
"message": "test"
}
}