Phonegap PushPlugin with a badge number and grouping feature - android

I have used pushPlugin to recieve push notification in my phonegap android application. Everything is working correctly. Only issue is when multiple messages are present in the notification bar, the last message overrides the previous message. I would like to group all the messages under the app as whatsApp does.
I tried adding notId parameter and setting it to random number from my server side code. Doing this actually displays multiple notifications but does not group then.
I would also like to know how to add badge number to my app. Basically a number which will tell the user that so many number of notifications are come. As it is in whatsApp (ex. 2 messages received). I have added this plugin to handle that, but I am not sure whether it has to be done in phonegap or will i have to modify java code (plugin) to achieve this.
I know this topic is addressed previously here but there is no answer to it. hence i have raised a new question. Any help would be appreciated.

I do think (although I totally am not sure) that WhatsApp doesn't actually show separate notifications, instead it concatenates the non-read messages on server before sending just one new notification that overwrites the current as you said. For example, if you initially have one message not read causing this notification
WhatsApp
Hey dude!
and then you receive another message, the notification sent is
WhatsApp
2 new messages from 2 contacts
or if the sender is the same contact
WhatsApp
Hey dude!\n
What is up?
You could use the pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler, event.badge);if you only needed iOS support but as it doesn't support the Android for that feature you need to use something else and that plugin you mentioned looks good for it. Seems like it is quite easy to use like this (after it is installed)
cordova.plugins.notification.badge.set(3);

Related

FCM differences between Android and iOS about data messages

I'm using Firebase Cloud Messaging to send data payload and display notification in my Android and iOS apps. I'm integrating this in my iOS app and I'm in front of a curious thing.
Short story:
My notification server only send data messages (I mean JSON messages containing "data" field and with no "notification" field). In my Android app this is not a problem because I receive the message even if my app is in background in my Service implementation and I manually build a notification that I display. But in iOS case, how can I receive message when my app is in background to do the same? I mean if I add a "notification" field to my request I see the notification pop on my screen (when app is in background) and I can get data (located in the "data" field) after a click when my app is in foreground.
But can I have data when my app is in the background to manually display a notification?
Important precision:
The content of the displayed notification should be built app side and not server side because the server doesn't have enough informations, this is why I can't send the "notification" field in my payload message.
Thanks
EDIT: I solve (in part) this problem using this link. Shortly, I enabled both Background fetch and Remote notifications under Background Modes (and added content_available : true in the payload). Then I can process data received in didReceiveRemoteNotification: But now it still one thing: how make it works when my app is killed?
EDIT 2: I found something that could be the thing : that. Modifying the payload of a remote notification implies to handle incoming notifications before there are displayed. I'll try.
EDIT 3: Firebase doesn't support the mutable-content key required to make my solution found at EDIT 2 working. Discussion about that is here. So... Any idea?
I do not think it is possible to trigger "stock" notification on iOS from code the same way you do on Android using NotificationBuilder.
The only option available is to use hybrid messages with both notification and data payloads.
Check their doc for more information on hybrid messages.
On 16/02/14, Firebase added compliance with the "mutable-content" key. So that solved my problem and, I think, many people's problems.
Personal thinking:
I consider that 6 months late for this feature is really too much. I hope that future releases'll be up to date with iOS (as well as Android) releases.

Alert Notifications from Asp.net to Android

HOW I TRIED:
I have a scenario in which teacher would upload an assignment alert on the server with following thing:
Title
Description
Downloadable Links
created date
Deadline
and the student would get these detail on an Android. I have done this work (the communication between server and client side using WCF webservices). All the data is showing in the ListView on client Side which are uploaded on the server.
WHAT I WANT
A push notification of that alerts on a particular dates e.g (if the teacher uploads an alert on 14 April then the user on the client side would get a push notification on the same date).
DealLine push notification of that alert on a particular dates e.g (the user would get a dealline notification of that assignment on a particular deal line)
I have studied about the GCM. is the best way to send a push notification on an android device. But I don;t think that the GCM is the appropriate solution of my problem? or I just simply go for the Android Notifications?
Does anyone suggest me the how can I do this work? Any appropriate solution for this, or I would have to use any third party library for this work? any tutorial that similar with this problem? THanks in Advance.

What should the payload be for Android push notifications (GCM)

From my understanding of the GCM documentation you basically send whatever data you want as the data field. Then the client receives it and is responsible for handling it and displaying it. Is this wrong? What if like on iOS I just wanted to send a bit of text and have it display? Is there a standard key to use or anything? I'm pretty certain I've been through all the documentation I can find and don't see anything like this.
No, you're right. There are no standard keys like in iOS, it's all up to you seeing as you're the one responsible for the notification management.
Basically, in your BroadcastReceiver you should write the code for displaying a Notification in the status bar. Just parse your JSONObject from the recieved message and show whichever piece of text you may have set.

How can I dynamically change the Notification message when I aggregate multiple notifications in Android?

I'm trying to perform this simple task dealing with push notifications in Android (C2DM):
if no notification exists in the notification bar, set it to "foo A"
if a notification already exists, grab it, read its text, and then update it to something like "N notifications: foo, bar, ...". This is similar to what the gmail client would do on Android when you get 1 email vs multiple ones
I have looked through the docs, read http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating, searched SO and the web, but so far, I don't see a way to get access to the notification currently in the notification bar.
Do I need to manage the count elsewhere and have it reset when the user dismisses the notification? Is there no way to read the existing one?
Thank you.
if a notification already exists, grab it, read its text, and then update it to something like "N notifications: foo, bar, ...". This is similar to what the gmail client would do on Android when you get 1 email vs multiple ones
No, it isn't. Gmail already has this information in a database. It does not need to "grab [a notification], read its text".
Moreover, what you want is impossible.
Do I need to manage the count elsewhere and have it reset when the user dismisses the notification?
Yes.
Is there no way to read the existing one?
No.

Can I send periodic messages to my Android app users?

Is it possible to make a app on Android such that whoever downloads this app receives a message from me weekly? I want to be the only person who can write on this message board and no one else. If this is possible, where should I start looking for tutorials about doing this sort of stuff?
You can create a RSS/Atom feed for yourself. Your android app can then just sync to this feed. Update the feed as often as you like. If you like this approach I can give more details.
yes , you can send periodic messages see this
in that SendMessage(); function is there so you have to make code for send message to recipient

Categories

Resources