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.
Related
I am having troubles to get Rich Push messages working with Urban Airship for Android. I tried to implement by myself looking at the tutorials, but after many tries i decided to test first the sample app from the github: https://github.com/urbanairship/android-samples/tree/master/RichPushSample
The problem is that is not working as i was expecting to work. I send the Rich Push messages from their testing website, and if i check the inbox i can see the new messages (and the old ones of course), but i never get a notification for those pushes.I didn't change anything in the code (neither in the AndroidManifest.xml).
Normal pushes are working fine, and debugging i can see how the RichNotificationBuilder creates the notification for normal pushes, and when tapped, the PushReceiver handles the intent. However for the Rich Push messages i never get a notification (thus i never receive intent in PushReceiver).
All the listeners they provide for rich push messages RichPushInbox.Listener, RichPushManager.Listener are only receiving when manually triggering inbox updates and so on (never when sending rich push from website)
Also tried sending them an email to their support email, but no answer.
Any help?
Thanks!
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.
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..
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.
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.