Search in sources :

Example 56 with JSObject

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);
    }
}
Also used : JSONArray(org.json.JSONArray) JSArray(com.getcapacitor.JSArray) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 57 with JSObject

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);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 58 with JSObject

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);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 59 with JSObject

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);
    }
}
Also used : JSObject(com.getcapacitor.JSObject)

Example 60 with JSObject

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);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Aggregations

JSObject (com.getcapacitor.JSObject)169 PluginMethod (com.getcapacitor.PluginMethod)93 JSONException (org.json.JSONException)28 JSONObject (org.json.JSONObject)20 MyRunnable (com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable)16 JSArray (com.getcapacitor.JSArray)14 Radar (io.radar.sdk.Radar)12 Uri (android.net.Uri)11 Location (android.location.Location)9 JSONArray (org.json.JSONArray)7 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 ParseException (java.text.ParseException)5 Intent (android.content.Intent)4 FirebaseUser (com.google.firebase.auth.FirebaseUser)4 Gson (com.google.gson.Gson)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4