Firebase data messages that work on android and iOS
Asked Answered
E

0

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

Evidentiary answered 18/5, 2017 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.