Monday, May 13, 2019

FCM (Firebase Cloud Messaging) :: User not receive offline message

              FCM (Firebase Cloud Messaging) ::  User not receive offline message 
When we move from GCM (Google Cloud Messaging) to FCM (Firebase Cloud Messaging) . During Testing we find out there is an issue in FCM i.e User not receive offline message . FCM API HTTP Response code is 200 :-


Then , I report this issue to  by filling necessary Details on there support URL :- .

During meantime I was checked by manipulating API Params . Then I find out adding time_to_live with some value for example 2419200 #four weeks its working fine . 

Same I communicate to @kat ( Support team) because it is bug from FCM . As per FCM document :- it is optional and the default value is 4 weeks.
Below mail send by google ( :-

Hi Saurabh, 

Thanks for the update. Happy to hear that adding time_to_live helped fix the issue.

This sounds like a bug, though. As you've noted from our documentation, requests that don't contain this field default to the maximum period of four weeks.


In Node Server we send notification by using below code :-

var request = require('request'); // npm i request                
if (TTL) {
                        TTL = 2419200; // Default TTL is four weeks.
// Before Background notificatin fix
//var postData ='{"data":{"title":"'+title+'","body":"'+body+'","icon":"'+ImageIcon+'","click_action":"'+weburl+'","requireInteraction":true,"tag":"'+Math.random()+'"},"to":"'+endpoint+'"}'; 

 var postData ='{"data":{"title":"'+title+'","body":"'+body+'","icon":"'+ImageIcon+'","click_action":"'+weburl+'","requireInteraction":true,"tag":"'+Math.random()+'"},"to":"'+endpoint+'","priority":10,"time_to_live": '+TTL+'}';
              var url = '';
                var options = {
                        method: 'post',
                        body: JSON.parse(postData),
                        json: true,
                        url: url,
                        headers: {'content-type' : 'application/json',
                request(options, function (err, res, body) {
                        if (err) {
                                console.error('error posting json: ', err)
                                throw err
                        var headers = res.headers;
                        var statusCode = res.statusCode;

No comments: