1

I am using phonegap-plugin-push with Ionic3.

In the plugin-push documentation

they are saying that on Android device we should use only data payload and not the notification in order the on('notification') will be triggered.

So far so good, but sending only the data payload, causing the notification tray to replace/overrides existing notification previously sent.

When sending notification payload, a new notification enters the notification tray without replacing existing one, but on tap event not triggered.

How can I achive both behaviors?

My payload:

{
   "message":{

      "android":
      {
         "data":{

            "title":"Hello",
            "body":"Hello",
            "timestamp":"2018-12-20T09:56:55.3250752+02:00"
         }
      },
      "apns":{
         "payload":{
            "aps":{
               "alert":{
                  "title":"Hello",
                  "body":"Hello",
                  "timestamp":"2018-12-20T09:56:55.3250752+02:00"
               }
            }
         }
      },
      "token": "f9j....."
   }
}
Nir-Z
  • 819
  • 1
  • 13
  • 31

1 Answers1

0

using a unique notId property in data payload solved the problem

{
   "message":{

      "android":
      {
         "data":{
            "title":"Hello",
            "body":"Hello",
            "notId": "1646269",
            "timestamp":"2018-12-20T09:56:55.3250752+02:00"
         }
      },
      "apns":{
         "payload":{
            "aps":{
               "alert":{
                  "title":"Hello",
                  "body":"Hello",
                  "timestamp":"2018-12-20T09:56:55.3250752+02:00"
               }
            }
         }
      },
      "condition": "'topic.test' in topics"
   }
}
Nir-Z
  • 819
  • 1
  • 13
  • 31