diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java index 24a44167f7..e607c57c22 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java @@ -73,18 +73,20 @@ public void schedule(PluginCall call) { return; } JSONArray ids = manager.schedule(call, localNotifications); - notificationStorage.appendNotificationIds(localNotifications); - JSObject result = new JSObject(); - JSArray jsArray = new JSArray(); - for (int i=0; i < ids.length(); i++) { - try { - JSObject notification = new JSObject().put("id", ids.getString(i)); - jsArray.put(notification); - } catch (Exception ex) { + if (ids != null) { + notificationStorage.appendNotificationIds(localNotifications); + JSObject result = new JSObject(); + JSArray jsArray = new JSArray(); + for (int i=0; i < ids.length(); i++) { + try { + JSObject notification = new JSObject().put("id", ids.getString(i)); + jsArray.put(notification); + } catch (Exception ex) { + } } + result.put("notifications", jsArray); + call.success(result); } - result.put("notifications", jsArray); - call.success(result); } @PluginMethod()