Prechádzať zdrojové kódy

fix crash on samsung devices, 500 alarms limit

PC Dreams (Paulo Cristo) 9 rokov pred
rodič
commit
6759116c16
1 zmenil súbory, kde vykonal 12 pridanie a 3 odobranie
  1. 12 3
      src/android/LocalNotification.java

+ 12 - 3
src/android/LocalNotification.java

@@ -37,6 +37,7 @@ import org.json.JSONObject;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
+import java.lang.Exception;
 
 import de.appplant.cordova.plugin.notification.Manager;
 import de.appplant.cordova.plugin.notification.Notification;
@@ -213,10 +214,18 @@ public class LocalNotification extends CordovaPlugin {
         for (int i = 0; i < notifications.length(); i++) {
             JSONObject options = notifications.optJSONObject(i);
 
-            Notification notification =
-                    getNotificationMgr().schedule(options, TriggerReceiver.class);
+            try {
+                Notification notification =
+                        getNotificationMgr().schedule(options, TriggerReceiver.class);
 
-            fireEvent("schedule", notification);
+                fireEvent("schedule", notification);
+            }
+            catch(Exception generic) {
+                //silently ignore the exception
+                //on some samsung devices there is a known bug where a 500 alarms limit can crash the app
+                //http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId=280286&listLines=15&startId=zzzzz%7E&searchSubId=0000000001
+                
+            }
         }
     }