How to prevent a notification from being sent to Wear? - android

i'm building an ongoing notification in my app.
I didn't found how to prevent it from being sent to wear.
i thought that ongoing notification were not sent but my notification is sent anymay. (i have used mBuilder.setOngoing(true);)
Anybody has an idea ?

In the Notification.Builder class you have a "setLocalOnly" method that allows you to configure this.

Related

Will silent push notification works if user turn off notification for the app?

Planning to use silent notification to refresh it's data when necessary. But I am worried that if users do not permit push notification, the app will not refresh data.
I am not sure if silent notification is different from normal notification in regards to permission.
Anybody has experienced this matter?
If you are talking about "data only messages" from firebase, yes, you will receive them normally as they don't use the Notification Manager API to publish a notification

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.

Removing notifications of other apps using deleteIntent

I'm using NotificationListenerService to read the notifications posted by other apps. In onNotificationPosted I get the deleteIntent of the notification and call deleteIntent.send() to remove the notification. This doesn't work for notifications posted by some apps! I have tried removing them using cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId()), but this also fails to remove them.
When swiping a notification on a phone or on a watch removes the notification from the phone, I expect firing deleteIntent explicitly, remove the notification as well.
Any ideas on why some notifications can't be removed?
The FLAG_NO_CLEAR has been set which prevents the notification from being cancelled.

Android Wear Notification Dismissed Listener

Has anybody found a way to trigger a callback/listener when a notification has been dismissed? Or any way to send a message or alter a data item on dismiss?
It seems to me this would be helpful for collecting analytics, but I haven't found a mechanism that allows for it.
NotificationCompat.Builder.setDeleteIntent (or the equivalent in Notification.Builder if you are doing local notifications on the Android Wear device) allows you to set a PendingIntent that will be called when your notification is dismissed.

Silent push notification in 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.

Categories

Resources