8

Im sending push notifications to both Android and iOS devices... I'm using data messages as I want need custom key value pairs and I need to use them when the app is in the background

my payload is something like:

{
   "to": "device token here",
   "content_available":true,
   "priority":"high",
   "data": {
      "key1": "value1",
      "key2": "value2",
      "key3": "value3",

  }
}

This works fine on Android, and notifications come through, on iOS a notification does not come through...It only comes through if i include notification in the payload like so:

{
   "to": "device token here",
   "notification": {
     "title": "test",
     "text": "MY Test"

   },  
   "content_available":true,
   "priority":"high",
   "data": {
      "key1": "value1",
      "key2": "value2",
      "key3": "value3",

  }
}

The problem with the second approach is that the notification no longer a data message, so I can't work with it when the app is in the background on android... How can I solve this - i need notifications to work on both platforms, sending data pairs, and ideally even when the app is in the background

Community
  • 1
  • 1
raklos
  • 28,027
  • 60
  • 183
  • 301

0 Answers0