Skip to content

Commit 0b89594

Browse files
committed
refactor(messaging, android): centralize remote message removal logic
it was duplicated, which means any fixes have to be in multiple spots
1 parent 2ca86df commit 0b89594

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ public void storeFirebaseMessage(RemoteMessage remoteMessage) {
3232
// save new notification id
3333
String notificationIds = preferences.getStringValue(S_KEY_ALL_NOTIFICATION_IDS, "");
3434
notificationIds += remoteMessage.getMessageId() + DELIMITER; // append to last
35+
preferences.setStringValue(S_KEY_ALL_NOTIFICATION_IDS, notificationIds);
3536

3637
// check and remove old notifications message
3738
List<String> allNotificationList = convertToArray(notificationIds);
3839
if (allNotificationList.size() > MAX_SIZE_NOTIFICATIONS) {
39-
String firstRemoteMessageId = allNotificationList.get(0);
40-
preferences.remove(firstRemoteMessageId);
41-
notificationIds = removeRemoteMessageId(firstRemoteMessageId, notificationIds);
40+
clearFirebaseMessage(allNotificationList.get(0));
4241
}
43-
preferences.setStringValue(S_KEY_ALL_NOTIFICATION_IDS, notificationIds);
4442
} catch (JSONException e) {
4543
e.printStackTrace();
4644
}

0 commit comments

Comments
 (0)