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.
Related
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
I am trying to figure out how Facebook / Twitter sends push notifications like "You have 20 new followers"I don't know how to call it but i want to learn the underlying algorithm of this in Android. Please help, Thanks !
On Android you can execute your code before actually showing a push notification. They could simply send a push notification to all devices with an identifier, then the app can make a request to the server and get the needed information in order to show the push notification.
They can also send one push notification per device, as they can associate the push notification key with the user login, and the server would fire a push notification every time there is an event that demands a push notification.
But there are also other ways of doing this, for example, they can, for example run locally in background and create a local notification when the app decides it is necessary.
I want to implement push notifications on both Android and iOS with Google Cloud Messaging.
I don't want to use the notification key in my payload because the Android behavior is not ideal. On Android, I would prefer my receiver to always get triggered with the data payload, and I can construct the Notification myself using NotificationCompat. If you use the notification payload on Android, you have no control over the notification style, for example.
However, if I only send a data payload, I think my iOS app will not receive the push if it is backgrounded - killed, never launched since device restart, etc. I think there's that content_available flag for GCM which may trigger the push anyway?
Am I, on iOS, able to duplicate the Android behavior of always having my in-app code execute upon notification? I'd be fine constructing my own iOS notification based on the GCM data payload, and perhaps using something like a UILocalNotification, but from what I'm reading, iOS is requiring the notification payload to exist to make sure the push is always received by the user.
Can I get this kind of control on iOS?
You have to disable the content_available flag to false, so that it works on Ios as expected and provide full control on android,
Source:- I have worked on Push Notification on both android and IOS recently
From my research, it seems that you can't avoid using the notification payload. However, you can get rid of the default Android behavior of auto-creating a notification, if, instead of creating a MyGcmListenerService that extends GcmListenerService, you create your own GcmListenerService and extend plain old Service.
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.
I am working on a chat application using phonegap for android, which is already running over web. I am sending messages through pushnotification and everything is working fine and notification is coming in status bar with default device sound setting. Now I want to sync some data from server without notifying user, means I need a notification that should just tell me that there is some new data on server to sync, without having status bar notification. I searched over web but couldn't found anything which can help me.
Any help would be great..
Thanks
Jaya
You could modify the plugin to not create a notification if a certain variable is set.
If you are using PushPlugin:
A notification is created only if you send message in the payload. But you will receive the payload in your application's callback. You can use this effectively to communicate with your application with having to implement anything additional.