Silent push notification in android - android

I've been used urban airship for notification and it's working.
Now client's requirement has been, he want to update a specific data (ie: current location) for client once any silent notification(no status bar notification) received. Could any one help me on this. Thanks

There is a couple of ways to send a silent notification to android devices. If you are using the built in notification builders, the notification will return null when the alert is empty. If you are using a custom one, just make sure its returning null when the alert is empty.
Then, send a notification with an empty alert. It will still come through on the push broadcast receiver.

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

Cancelling a notification received in background from GCM (Android)

I'm using Google Cloud Messaging to receive new orders into an app. I'm trying to handle cases where the same order is sent twice. I just want the second receipt to be ignored, unfortuntately when the app is in the background I dont seem to be able to cancel the notification (ie it still makes a noise and sends a message). The app works fine when in the foreground, putting cancel notification code in my GCMBrodacastreceiver doesnt seem to do anything. Am I missing something?
NotificationManager mNotify = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotify.cancelAll();
You can set the "tag" field in the notification payload. If you use this the incoming notification will just update any existing one with the same tag.
cancelAll() will dismiss the notification, but your code may not be invoked when the app is in the background as the notification will be posted without your app's code running. One option would be to have your server not send the notification if it has already sent one recently.

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.

Intercept push notification from showing in app

I need to have a toggle for push notifications in my app, but I can't make changes in server. Can I intercept the push message in GCM and not show it in the topbar?
Since you are the one displaying the notifications, you do not have to "intercept" anything. You are already receiving the GCM messages, with the code that you wrote, where your code is displaying the Notification. Simply have that code examine your SharedPreferences (or wherever the "toggle" is stored) to see if the code should actually display the Notification.

Receive but not show GCM push notification

Is it possible to receive a GCM push notification but choose to not show it in the notification bar under certain circumstances? On an incoming push notification, I would like to do a check of whether or not the user is within a specified location or not, and only show the push notification in the notification bar if the user is within this location. I'm using Urban Airship.
Thanks in advance
Update:
To clarify: in the Urban Airship intent receiver, I have the onReceive() method, which I thought was what I was supposed to modify in order to conditionally show the push notification. However, it seems that this intent is only for showing logging information and I suspect that the real receiving intent is baked into the Urban Airship .jar file as the .class file com.urbanairship.push.GCMPushReceiver, which contains the onMessage() method. Since this is not the source code, it seems it would be difficult to modify this part since it is linked to the numerous other components. Does anybody have any idea on how this could be done?
It is definitely possible: push notifications are information to the device, but on Android they aren't automatically shown. You can choose to not display a notification at all. With Urban Airship you can probably just replace their default receiver with one of your own to prevent it from displaying in the notification area.

Categories

Resources