Stacking push notifications in Delphi to Android application - android

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:
Store it to sqlite
Calculate the notification ID you need to display that notification (can be a hashCode of the notification type ?)
Fetch all notif for that type from sqlite
Cancel the notification with this ID (don't worry, cancelling a non existing notification won't make your app crash)
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.

Related

Choose to show or ignore push notifications client side?

We want to send push notifications in Android and iOS to a group of users that match a certain condition. We can check if an user match this condition calling an API.
Our problem is that the users information changes very quickly and we don't have any way to keep track of this in our push notifications engine (OneSignal).
The only alternative we can think is to send the push notification to all users and client side call the API to get the latest user information. Depending on this we could choose to show the notification or ignore it.
Is this possible on Android and iOS?
It is 100% possible for sure. in the receiver class you call an intentservice, which can hit an api and get the latest information, based on the information you create notification using notification builder, and avoid if you dont want.
Yes, with the help of NotificationExtenderService this is possible.
Receive a notification in the background. Notification data is wrapped up in OSNotificationReceivedResult object. Now, read the notification id/title which should be unique for every notification.
Send this unique notification title/id along with user id to an API, which will return whether to show the notification to the user or not. If true then read notification title and message/description from OSNotificationReceivedResult and make a notification via NotificationCompat otherwise just ignore it.
Reference

How to Combine N Number of Related Android Push Notifications

I have been reading many posts/articles/tutorials I can find about updating an active notification. I fear I may have a fundamental misunderstanding about how one may update an Android push notification.
So far: I can update an active notification based on its ID, and I haven't been able to get any results out of Builder.setGroup()
My problem: When I update an active (not dismissed) notification, I want to be able to get the text from the previous, active notification, parse and add the new notification text and update it.
I'm starting to think that this might not be possible without a local DB and that my approach to this problem is no good.
Is there a way to get the content of the last notification (or one with a specific ID)?
EDIT: It seems to me that many of the examples I have seen are grouping a number of notifications all at once rather than successively.
Example
This is an example of what I want to do. The scenario I'm imagining is like this:
The owner of the device gets a notification that he/she has a new message from 'Alex Faaborg'. (See image)
The notification is not dismissed by the device owner
Another notification regarding a new message from 'Jeff Chang' comes in
Get 'Alex Faarborg's' name from the first notification, and 'Jeff Chang' from the second
Parse the info and display a summary of their notifications rather than have multiple notifications build up
4 is what I'd like to do
OK, so I realized I could do what I need to do to combine notifications by keeping track of users' unread messages(or invites etc..) on the backend, then if there's more than one, it will send out a summary of the notifications rather than each individually. On the client, this will overwrite any previous, related notifications (kept track with a JSON field sent to GCM (and subsequently, the client) that represents the 'topic' of the notification)
For whatever reason, I thought I should handle the grouping/summarizing of notifications on the client. I think the API is the way to go.

Parse Android Push Do not display notification

I'm using Parse to send push messages to my app. In some cases I want to show a notification however in some cases I don't. For example when data should be updated I intend to send a notification to all devices so that way they don't have to poll. This should not show any notification.
Parse's GcmBroadcastReceiver seems to always generate a notification without any way of turning that off.
I'm also curious of how to stop Parse from auto-creating a notification because at some point I'm going to want to work with more complex notifications, which Parse doesn't support.
I've tried creating my own GcmBroadcastReceiver however when I did that I didn't receive anything. Maybe I rigged it wrong? Other than that how can I stop Parse SDK from auto-generating a notification?
Omit alert and title from your push notification and the parse.com android SDK will not create a notification.

Handling Parse Push Notifications in Android

I am using Parse API in order to handle push notifications. In our Android application, I want to accomplish two things:
1) If we have received a Push Notification with the application is closed and the user clicks on the notification, I want to be able to understand that the application is being opened via a push notification.
2)If we receive a push notification while the application is open, I want to handle this and do some extra work.
In both cases, I want to be aware that the application has received a push notification in order to execute some special operations.
As far as I understand from Parse API documentations, it offers two methods of handling pushes: Responding with an Activity and Responding with an Intent. I am currently calling
PushService.setDefaultPushCallback(context, MainActivity.class);
in my Application class with needed changes in the AndroidManifest.xml file and already receive push notifications, this corresponds to Responding with an Activity method. But I don't know how to be aware of Push Notifications explicity with this method.
Thanks in advance.
When a push is received ,Check
1:Whether our application is in foreground or background.
If it is foreground, that means app is visible and do your stuff(show alerts or anything you want).
If app is in background,that means it is not visible and if you want to do any thing based on this.
i hope this helps..

how to impliment Notifications aggregation

My application displays event notifications, and I'm looking for a way to have notification aggregation.
Meaning, I would like to show 4 notification, but if the fifth comes, I would like to collect all notifications and show only one general notification.
Os there a way to know how many live notifications i have?
Is it possible to approach these notification and cancel them?
Thanks!
According to the android design guidelines you should stack your notifications. So you should avoid showing multiple notification for the same app.
You can stack your notifications using
NotificationManager.notify(ID, notification) where you specify same ID for each notification.
You can check the docs on how to implement it.
For your case
Is there a way to know how many live notifications i have - No
But you can keep a track of the notifications using Shared Preferences, where you store the ID of the notificaion and remove it when the user clicks on the notificaion
Is it possible to approach these notification and cancel them? - Yes
You can cancel a notification using the cancel(int id) method, where you pass the ID of the notification to be removed.
So you can use this method to acheive what you want, but it advisable to stack all the notifications.

Categories

Resources