Ionic push notifications with payload in "Ionic Serve" testing mode


I am trying to test the “payload” in push notifications.
Two questions:
(1) How can I pass a payload that will be delivered to all platforms (ios, android, etc)?
(2) I pass it to both ios and android separately, but it doesn’t arrive when I test it in “ionic serve” browser mode… And that’s really problematic… How can I mimic a specific platform, for example android, when I run ionic serve?

You can only really test how it will work on the device … on a device. This is made worse by the (intentionally) crippled implementation (no title, no payload, only text) of dev_push (polling to a server instead of real push). There is not much you can do about that.

One workaround is do tamper the notification object in the handler for pushes:

if(notification.title == 'DEVELOPMENT PUSH') {
  // do special stuff to the notification object here

What is normally sent as paycode.transaction_id I sent as the notification text (notification.text) for dev_pushes and then copy it to paycode.transaction_idin here… Works, but is very ugly.

Are you from the Ionic dev team? Shouldn’t it be a simple feature to run the ionic serve with mimicking a specific device? After all, there is the option to do ionic serve --lab

Nope, just a normal (newbie) user as you are.

You cna mimick a device using ionic serve, just open the page in Chrome, open Chrome developer tools and then switch to Device mode and select the device. This will put the display in the correct size and also fake the user agent, so Ionic will show the correct CSS.

BUT this will not emulate the whole device with its sensors, hardware, all the functionality. This would be a massive amount of work. (Also, that’s what emulators are here for.)

Thanks - I meant only in respect from getting push notification as an android device, with the payload… Hopefully someone from the Ionic team will pick it up.

One could presume they intentionally crippled the dev_push implementation to make sure nobody tries to use it in production. But maybe that’s BS and it’s just that because some other reason.

Anyway, it forces you to got to the emulator or device, which is almost always a good thing.