Skip to content

Commit

Permalink
fix(android): Avoid crash on schedule if LocalNotifications are disab…
Browse files Browse the repository at this point in the history
…led (#2718)
  • Loading branch information
jcesarmobile authored Apr 7, 2020
1 parent 327ffc5 commit aac51fe
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit aac51fe

Please sign in to comment.