From c6689a9c5d6d0e202dbf028ec89cd5923b76b4d9 Mon Sep 17 00:00:00 2001 From: Noam Bonnie Date: Tue, 19 Jun 2018 07:41:31 -0400 Subject: [PATCH] Support for Android group alert behavior --- .../evollu/react/fcm/SendNotificationTask.java | 17 +++++++++++++++++ index.d.ts | 2 ++ 2 files changed, 19 insertions(+) diff --git a/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java b/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java index df96635..0376a78 100644 --- a/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java +++ b/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java @@ -92,7 +92,24 @@ public class SendNotificationTask extends AsyncTask { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ String group = bundle.getString("group"); if (group != null) group = URLDecoder.decode( group, "UTF-8" ); + notification.setGroup(group); + + String groupAlertBehavior = bundle.getString("groupAlertBehavior", "all"); + switch(groupAlertBehavior) { + case "children": + notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN); + break; + case "summary": + notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY); + break; + case "all": + notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL); + break; + default: + notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL); + } + if (bundle.containsKey("groupSummary") && bundle.getBoolean("groupSummary")) { notification.setGroupSummary(true); } diff --git a/index.d.ts b/index.d.ts index ac9fa5a..74dfe4b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -89,6 +89,8 @@ declare module "react-native-fcm" { ticker?: string; auto_cancel?: boolean; group?: string; + groupSummary?: boolean; + groupAlertBehavior?: string; picture?: string; ongoing?: boolean; lights?: boolean; -- 2.26.2