-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Crashes in production app for local notifications #1135
Comments
This is urgent |
Finally discovered what was it! Some users had scheduled notifications from an ancient version that used hashes for IDs and they could never be canceled because the cancellation crashed. Not sure if I should submit this as a PR, but here's the patch. It tries to remove the notification but if the parsing fails it only removes it from the persistence database. --- node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java.orig 2020-05-13 14:11:17.749444849 -0300
+++ node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java 2020-05-13 14:17:01.652609184 -0300
@@ -517,11 +517,20 @@
private void cancelScheduledNotification(String notificationIDString) {
Log.i(LOG_TAG, "Cancelling notification: " + notificationIDString);
+ try {
+ int notificationID = Integer.parseInt(notificationIDString);
- // remove it from the alarm manger schedule
- Bundle b = new Bundle();
- b.putString("id", notificationIDString);
- getAlarmManager().cancel(toScheduleNotificationIntent(b));
+ // remove it from the alarm manger schedule
+ Bundle b = new Bundle();
+ b.putString("id", notificationIDString);
+ getAlarmManager().cancel(toScheduleNotificationIntent(b));
+
+ // removed it from the notification center
+ NotificationManager notificationManager = notificationManager();
+
+ notificationManager.cancel(notificationID);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
if (scheduledNotificationsPersistence.contains(notificationIDString)) {
// remove it from local storage
@@ -531,11 +540,6 @@
} else {
Log.w(LOG_TAG, "Unable to find notification " + notificationIDString);
}
-
- // removed it from the notification center
- NotificationManager notificationManager = notificationManager();
-
- notificationManager.cancel(Integer.parseInt(notificationIDString));
}
private NotificationManager notificationManager() {
|
Hi @fauno |
hi @Dallas62 no, i don't usually upgrade to latest versions because it usually means i have to spend several weeks checking if they're still compatible to the whole app, but i did upgrade from 3.1.2 to 3.1.9 last week because if i recall correctly there were some commits i wanted. anyway i checked the current code as is the same i patched, can you point me to where it should be fixed? the issue was that when i changed to numerical string ids the previous scheduled notifications couldn't be cancelled anymore (i think it was when i upgraded from 2.2.1 to 3.1.2 according to git log, and that was on 2018!). it may be too specific to my case though. it was a known bug to me but only recently users started to report about it and i could get the information required to fix it (play console was showing the exception but not the failing string) :) |
Actually latest version is close to the initial interface. A breaking change which wasn't identify occurs when a user open the Application. Initially data where directly included in the notification object. Now they are in Changes for this bug is here: The latest is in case of invalid value (like NaN). |
thanks! these notifications are only local though. i'll take a look anyway! |
This also impact scheduled notifications, I notice that on my Application. iOS is like 🚀 but Android is stuck 👎 after the change, the Android retention is growing again. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
Hi, I've used this package for an app that only shows local notifications and everything works fine, but Play Console is telling me 10% of the users (~1000 people) are experiencing this crash:
I'm running cancelAllLocalNotifications() only once in the code and made sure every notification is created with numeric string ids as the doc says, but I'm not sure why would it want to parseInt() them. Since I can't reproduce it on development I'm not sure how should I debug it. Any ideas? :)
The text was updated successfully, but these errors were encountered: