I'm attempting to send a silent data notification to an iOS device using node.js module firebase-admin 7.0.0 and the following code:
// load lib
var firebase = require('firebase-admin');
// add API keys
firebase.initializeApp({
credential: firebase.credential.cert('./certs/firebase-private-key.json')
});
// device token send back from device
var token = '00397db1aa2f1fa625f71deef0c8e8ef0d4427cf60a13c0fb4bd290dcec41f4b';
// data message to send (contains no notification details so should be silent)
var message = {
data: {
key1: 'hello',
key2: 'world'
}
};
var options = {
priority: 'high',
timeToLive: 60 * 60 * 24,
contentAvailable: true,
mutableContent: true
};
// send the message
firebase.messaging().sendToDevice(token, message, options).then(function (res) {
// it worked!
console.log(res);
})
.catch(function (err) {
// it failed :(
console.log(err);
});
I get a response saying the message was sent, but it never arrives on the device. Whereas if I send the message using NWPusher it works fine (example payload below):
{"aps":{ "content-available": 1,"badge":0, "hello": "there" }}
Any ideas?
FYI: I have also opened a ticket on GitHub