use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class LocalNotificationsPlugin method schedule.
/**
* Schedule a notification call from JavaScript
* Creates local notification in system.
*/
@PluginMethod
public void schedule(PluginCall call) {
List<LocalNotification> localNotifications = LocalNotification.buildNotificationList(call);
if (localNotifications == null) {
return;
}
JSONArray ids = manager.schedule(call, localNotifications);
if (ids != null) {
notificationStorage.appendNotifications(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.getInt(i));
jsArray.put(notification);
} catch (Exception ex) {
}
}
result.put("notifications", jsArray);
call.resolve(result);
}
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class LocalNotificationsPlugin method getPending.
@PluginMethod
public void getPending(PluginCall call) {
List<LocalNotification> notifications = notificationStorage.getSavedNotifications();
JSObject result = LocalNotification.buildLocalNotificationPendingList(notifications);
call.resolve(result);
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class LocalNotificationsPlugin method areEnabled.
@PluginMethod
public void areEnabled(PluginCall call) {
JSObject data = new JSObject();
data.put("value", manager.areNotificationsEnabled());
call.resolve(data);
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class LocalNotificationsPlugin method handleOnNewIntent.
@Override
protected void handleOnNewIntent(Intent data) {
super.handleOnNewIntent(data);
if (!Intent.ACTION_MAIN.equals(data.getAction())) {
return;
}
JSObject dataJson = manager.handleNotificationActionPerformed(data, notificationStorage);
if (dataJson != null) {
notifyListeners("localNotificationActionPerformed", dataJson, true);
}
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class LocalNotificationsPlugin method checkPermissions.
@PluginMethod
public void checkPermissions(PluginCall call) {
JSObject permissionsResultJSON = new JSObject();
permissionsResultJSON.put("display", getNotificationPermissionText());
call.resolve(permissionsResultJSON);
}
Aggregations