After reading the post and comments, I donβt quite understand everything that was tried, which efforts were successful and which failed. I will cover the number if items and hope something useful.
Your message indicates that for some tests you specified a collapse key when you composed the message in the Firebase console. It's impossible. If you open the "Advanced" option and enter the key / value pair in the "User Data" section, this will not work. These values ββare stored in the message under the data key, and not at the top level of the message in which collapse_key should appear. In addition, Table 1 in the documentation contains a warning that the data keys should not be reserved words in the table, in particular, referring to collapse_key :
The key must not be a reserved word ("from" or any word starting with "google" or "gcm"). Do not use any words defined in this table (e.g. collapse_key ).
As noted in the comments to the message, the console automatically assigns a collapse key, which is the name of the package, so user input of the collapse key is not required.
However, my experience with the console matches yours. I create messages by entering only the message text and the device token. I do not see the processing of collapse; each message is received by the device. Based on my experience described below, this seems to be a problem with the console, and not with collapse handling in general. This is strange because if I send messages when the application is in the foreground and onMessageReceived() is onMessageReceived() , I have a debug log that displays the failure key in the message using getCollapseKey () . This conclusion confirms that the key is present and is the name of my application.
You will indicate that you have completed some tests sending notifications from the cloud function. I did my own testing using this cloud function and noticed that the expected message crash:
exports.test = functions.database.ref('/test').onWrite(event => { const token = 'dK1FjGbNr6k:APA91bH7Vz3x...icGO56sJ7rAqOXRI'; console.log('Sending notification...'); const payload = { notification: { title: 'Message', body: 'Just one please!' } }; const options = { collapseKey: 'green' }; return admin.messaging().sendToDevice(token, payload, options).then(response => { console.log('Done'); }); });
I also sent this message using the Advanced Rest Client application browser, and also saw the message merge correctly:
{ "to": "dK1FjGbNr6k:APA91bH7Vz3x...O56sJ7rAqOXRI", "collapse_key": "green", "notification": { "title": "Message", "body": "Just one please!" } }
I will also tell you that Firebase sends an analytics log message when it receives a notification. This is useful for testing when you want to get the number of messages received:
D/FA: Logging event (FE): notification_receive(_nr), Bundle[{firebase_event_origin(_o)=fcm, message_device_time(_ndt)=0, message_time(_nmt)=1498227476, message_id(_nmid)=6447126672094369335}]