Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 32fe0da

Browse files
committed
Fix regression on the importance of the channel notification.
1 parent 5695070 commit 32fe0da

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,38 @@ public void sendToNotificationCentre(Bundle bundle) {
206206
}
207207
}
208208

209-
channel_id = channel_id + "-" + priority;
209+
int importance = NotificationManager.IMPORTANCE_HIGH;
210+
final String importanceString = bundle.getString("importance");
211+
212+
if (importanceString != null) {
213+
switch(importanceString.toLowerCase()) {
214+
case "default":
215+
importance = NotificationManager.IMPORTANCE_DEFAULT;
216+
break;
217+
case "max":
218+
importance = NotificationManager.IMPORTANCE_MAX;
219+
break;
220+
case "high":
221+
importance = NotificationManager.IMPORTANCE_HIGH;
222+
break;
223+
case "low":
224+
importance = NotificationManager.IMPORTANCE_LOW;
225+
break;
226+
case "min":
227+
importance = NotificationManager.IMPORTANCE_MIN;
228+
break;
229+
case "none":
230+
importance = NotificationManager.IMPORTANCE_NONE;
231+
break;
232+
case "unspecified":
233+
importance = NotificationManager.IMPORTANCE_UNSPECIFIED;
234+
break;
235+
default:
236+
importance = NotificationManager.IMPORTANCE_HIGH;
237+
}
238+
}
239+
240+
channel_id = channel_id + "-" + importance;
210241

211242
int visibility = NotificationCompat.VISIBILITY_PRIVATE;
212243
final String visibilityString = bundle.getString("visibility");
@@ -379,7 +410,7 @@ public void sendToNotificationCentre(Bundle bundle) {
379410
notification.setVibrate(vibratePattern);
380411
}
381412

382-
checkOrCreateChannel(notificationManager, channel_id, soundUri, priority, vibratePattern);
413+
checkOrCreateChannel(notificationManager, channel_id, soundUri, importance, vibratePattern);
383414

384415
notification.setChannelId(channel_id);
385416
notification.setContentIntent(pendingIntent);
@@ -637,7 +668,7 @@ private static void commit(SharedPreferences.Editor editor) {
637668
public void checkOrCreateDefaultChannel() {
638669
NotificationManager manager = notificationManager();
639670

640-
int importance = NotificationCompat.PRIORITY_HIGH;
671+
int importance = NotificationManager.IMPORTANCE_HIGH;
641672

642673
String channel_id = NOTIFICATION_CHANNEL_ID + "-" + importance;
643674

0 commit comments

Comments
 (0)