Hello ,
I am creating custom notification view using extender but I am not able to dismiss notification when action button is clicked neither pending delete intent is getting fired.Below is my sample code:
final PendingIntent pendingDeleteIntent = PendingIntent.getBroadcast(getApplicationContext(), 104, new Intent(getApplicationContext(), DismissNotificationReceiver.class), 0);
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
return builder.
setDeleteIntent(pendingDeleteIntent)
.setAutoCancel(true)
.setContentTitle(message)
.setGroup("1")
.addAction(action)
.setStyle(new NotificationCompat.BigTextStyle().bigText(timeLapse))
.setContentText(timeLapse);
@himgupta There isn't an AutoCancel for buttons that you add to the notification. You will need to run the following after your intent if fired to remove the notification.
// This is the id from displayNotification(..) called from your NotificationExtenderService.
int notificationId = 123;
NotificationManagerCompat.from(inContext).cancel(notificationId, 0));
However if possible we recommend setting action buttons on the notification when sending it. This way the dismiss is taken care of for you along with the the click being tracked on the dashboard.
I am not able to get any call back in my delete intent.Can you please telll if deleteintent works
@himgupta It does not at this time, see issue https://github.com/OneSignal/OneSignal-Android-SDK/issues/86 for more details.
Can we close the notification on click of particular action button without opening app in android.
I'm looking for this behaviour too. Would like the app to remain closed on action button click.
@rf1804 Maybe this is what you are looking for
<application ...
<meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
</application>
Most helpful comment
Can we close the notification on click of particular action button without opening app in android.