0

I am trying to get push notifications working for iOS applications for a nodeJS server. I have been able to configure it correctly for android using FCM tokens that are being sent to me. But I am unable to do the same for iOS. I tried to google online but the resources are fairly old and my iOS teammate said that he has configured everything on his end correctly. More so, after logging the output of the firebase admin package on nodeJS, I am getting a successful message ID as well. Any suggestions as to what can be done. I am attaching the nodeJS code as well for reference.

var data = {
    notificationPriority: 'high',
    notificationTTL: 3600
};
const fireadmin = require('firebase-admin');
fireadmin.initializeApp(
    {
        credential: fireadmin.credential.cert(keys.serviceAccount),
        databaseURL: keys.databaseURL
    }
);

var options = {
    priority: data.notificationPriority,
    timeToLive: data.notificationTTL
};
var payload = {
    data: {
        title: 'Test',
        message: 'Message'
    },
}

RegId.findOne({ userID: mongoose.Types.ObjectId(userID) }).then(tokenData => {
    fireadmin.messaging().sendToDevice(tokenData.registrationToken, payload, options).catch(err => console.log(err))
}).catch(err => console.log(err))
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Hi Sahil Doshi, have you made sure that APNS Key has been uploaded? https://firebase.google.com/docs/cloud-messaging/ios/client#upload_your_apns_authentication_key Also, make sure you are testing in Appropriate Env [Sandbox, Production] – Mayur Tanna Sep 12 '21 at 13:33
  • Hi, I checked with my iOS team. This has been done. But does this require any changes from the nodeJS side? Because my code for android and iOS is the same. – Sahil Doshi Sep 14 '21 at 22:14

0 Answers0