I am using https://github.com/ToothlessGear/node-gcm to send message using GCM to chrome packaged apps.
Everything works fine if chrome app is running
When I am sending the message while chrome app is closed, those messages are not delivered after starting the app. I do get the message_id in the result at server.
I also tried using command line, facing the same problem in command line too.
Code at server side(nodejs)
var GCM = require('node-gcm');
var gcmSender = new GCM.Sender(apiKey);
var sendGCMMessage = function(data, regIds, collapseKey, callback) {
var message = new GCM.Message({
priority: 'high',
collapseKey: collapseKey,
data: data
});
gcmSender.send(message, regIds,
function(err, result) {
callback(err, result)
})
}
Packaged Apps:
//register
var senderIds = [senderId];
chrome.gcm.register(senderIds, function(registrationId) {
sendRegistrationIdToServer(registrationId, function(succeed) {
});
});
//listen to incoming messages
chrome.gcm.onMessage.addListener(function(message) {
console.log("gcm message")
});