firebase-admin-node: messaging/internal-error only IOS

code is working fine when I try to send notification on android but it does not work for IOS notification. Getting the below error:

{
  "results": [
    {
      "error": {
        "code": "messaging/internal-error",
        "message": "An internal error has occurred. Please retry the request."
      }
    }
  ],
  "canonicalRegistrationTokenCount": 0,
  "failureCount": 1,
  "successCount": 0,
  "multicastId": 8118740071861272000
}

This is my code sample

return await admin.messaging()
          .sendToDevice(deviceToken, {
   data: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high',
       requestId: '1',
       doctorId: '1',
       name: 'waqas',
       patientId: '1',
       action_type: 'TEST'
     },
     notification: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high'
     }
   }
  , {
   priority: "high",
   timeToLive: 60 * 60 * 24,
   contentAvailable:true,
}).catch(err => {
              console.log(err);
            
          })

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

This is still not reliably working for me. I have ‘body’ instead of ‘text’, and I don’t have ‘content-available’ in the payloads. It only randomly fails, works 80-90% time.

Found the issue - They recently changed it on FCM so they do not allow to sent TEXT and BODY keys. From now on - we should only use the “Body”. Once I removed the “Text” key from the notification object - everything works fine again.

My Code is Nodejs, Its not working only IOS , Android is working fine Error return : internalServerError async function PNF(data){ var fcm = new FCM(process.env.FCM_KEY); var message = { to:data.token, code:data.code, data:data.body, notification: { title: ‘Posterz’, body: data.title, sound: “ping.aiff”,

      }
    };
console.log(JSON.stringify(message),"======================= android push");
fcm.send(message, function(err, response) {
  if(err){
    console.log('error found', err);
  }else {
    console.log('response here', response);
  }
})

}

Any updates on this? We have this error happening intermittently; overall we can’t seem to use Firebase reliably to send notifications to users, and our users depend on it.

they answered me in this way:

This is Yuji. Happy to help you out.

There was an outage regarding internal server errors for iOS devices, that affected a small percentage of users. It will give an error when the request has multiple “content_available” parameters, which is the issue in your case. A number of customers have been affected by a change that was recently made to the API service. The issue was escalated to our engineering team and a mitigation was rolled out.

If you have any other questions or concerns, feel free to reach back. Cheers,

I removed "contentAvailable" in the payload.options object and it worked 👍