You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this SO post they discuss the difference between data and display messages (the main difference being data messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed).
I've been trying to use this library (through node-pushnotifications) but it appears the messages are being sent as display notifications. How do I change the type to data so the callback will be triggered even if the app is in the background?
The text was updated successfully, but these errors were encountered:
Hi @0x62,
Using this sample code only a data payload is sent and not a notification display payload:
vargcm=require('node-gcm');// Set up the sender with your GCM/FCM API key (declare this once for multiple messages)varsender=newgcm.Sender('YOUR_API_KEY_HERE');// Prepare a message to be sentvarmessage=newgcm.Message({data: {key1: 'msg1'}});// Specify which registration IDs to deliver the message tovarregTokens=['YOUR_REG_TOKEN_HERE'];// Actually send the messagesender.send(message,{registrationTokens: regTokens},function(err,response){if(err)console.error(err);elseconsole.log(response);});
In this SO post they discuss the difference between data and display messages (the main difference being data messages trigger the
onMessageReceived()
callback even if your app is in foreground/background/killed).I've been trying to use this library (through
node-pushnotifications
) but it appears the messages are being sent as display notifications. How do I change the type to data so the callback will be triggered even if the app is in the background?The text was updated successfully, but these errors were encountered: