Adding data to notification

Hi,

currently I get notifications like:

{"data":{},"from":"12345","messageId":"0:123456789","messageType":null,"notification":{"tag":null,"body":"Kid has exited geofence School at 2019-02-20 12:31:44","bodyLocalizationArgs":null,"bodyLocalizationKey":null,"clickAction":null,"color":null,"icon":null,"link":null,"sound":null,"title":null,"titleLocalizationArgs":null,"titleLocalizationKey":null},"originalPriority":1,"priority":1,"sentTime":1550658705212,"to":null,"ttl":2419200}

Is there a way to add data? I mean, things like:

"data":{"event":"exit_geofence", "deviceId":"9876543", "geofenceId":3}
Anton Tananaev5 years ago

I literally have no idea what you are talking about. I don't event understand where you got the original JSON from.

Ah, sorry. So I set firebase notifications, and I looked at them in an android app. This is all the data that's in the firebase notification I received. And theoretically it is possible to pass key-value pairs in the data field. I wonder if it's possible to configure somehow to pass there certain data, like the example I gave above.

Anton Tananaev5 years ago

You would need to change source code to include additional data.

What is your preferred way to do it? Can I add it to every notification?

Anton Tananaev5 years ago

Depends on what exactly you want to add. It doesn't make sense to add geofence to every notification.

Yeah, of course. I would only add what exist depending on the event. What I meant on "every" is that it's ok to send for example on a "left geofence" event for every firebase notification or should it be configured?

Anton Tananaev5 years ago

I don't see any problem with sending extra data. As long as it doesn't break any functionality.