简体   繁体   中英

Stacking push notifications in Delphi to Android application

In my delphi code app, Is possible I change the settings of my pending intent used to handle push notifications when It arrives? I´d like to change your behaviour. Instead I have many push icons notifiactions on status bar when each new push messages arrive, I´d like to have only one with a counter increasing when new push messsages arrive. I´d like something as https://developer.android.com/training/wearables/notifications/stacks.html

Luiz

You can implement the logic you want. When you receive a push, it carries various data. If a notification is already displaying such data, you can cancel the existing notification and create a new one.

In any way, the notification manager of android will be able to stack notifications by itself for you.

So i suggest, when you receive data from a push:

  1. Store it to sqlite
  2. Calculate the notification ID you need to display that notification (can be a hashCode of the notification type ?)
  3. Fetch all notif for that type from sqlite
  4. Cancel the notification with this ID (don't worry, cancelling a non existing notification won't make your app crash)
  5. Create a shiny new notification with all the data you fetched, if you have more than one, you might want to display "+X other".

EDIT: With my answer, i assumed you can do as much as thing in "delphi to android" than in native android. Hence, i can't provide code for you, but the idea does not depend of the language you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM