Skip to content

Commit 56553db

Browse files
committed
fix(messaging): enforce min stored notification limit
1 parent 41ca8ef commit 56553db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ReactNativeFirebaseMessagingStoreImpl implements ReactNativeFirebas
2727
private static final String S_KEY_ALL_NOTIFICATION_IDS = "all_notification_ids";
2828
private final String DELIMITER = ",";
2929
private static final int DEFAULT_MAX_SIZE_NOTIFICATIONS = 100;
30+
private static final int MIN_SIZE_NOTIFICATIONS = 20;
3031
private static final int maxNotificationSize = resolveMaxNotificationSize();
3132

3233
private static int resolveMaxNotificationSize() {
@@ -47,8 +48,8 @@ private static int resolveMaxNotificationSize() {
4748
maxSize = meta.getIntValue(KEY_MAX_STORED_NOTIFICATIONS, DEFAULT_MAX_SIZE_NOTIFICATIONS);
4849
}
4950

50-
// Safety cap: prevent values > 100 to avoid re-introducing OOM risk
51-
return Math.min(maxSize, DEFAULT_MAX_SIZE_NOTIFICATIONS);
51+
// Clamp to allowed range to avoid OOM (upper) or mass deletions (lower)
52+
return Math.max(MIN_SIZE_NOTIFICATIONS, Math.min(maxSize, DEFAULT_MAX_SIZE_NOTIFICATIONS));
5253
} catch (Exception e) {
5354
// Ignore and use default
5455
return DEFAULT_MAX_SIZE_NOTIFICATIONS;

0 commit comments

Comments
 (0)