use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class PushNotificationsPlugin method removeDeliveredNotifications.
@PluginMethod
public void removeDeliveredNotifications(PluginCall call) {
JSArray notifications = call.getArray("notifications");
List<Integer> ids = new ArrayList<>();
try {
for (Object o : notifications.toList()) {
if (o instanceof JSONObject) {
JSObject notif = JSObject.fromJSONObject((JSONObject) o);
Integer id = notif.getInteger("id");
ids.add(id);
} else {
call.reject("Expected notifications to be a list of notification objects");
}
}
} catch (JSONException e) {
call.reject(e.getMessage());
}
for (int id : ids) {
notificationManager.cancel(id);
}
call.resolve();
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class PushNotificationsPlugin method handleOnNewIntent.
@Override
protected void handleOnNewIntent(Intent data) {
super.handleOnNewIntent(data);
Bundle bundle = data.getExtras();
if (bundle != null && bundle.containsKey("google.message_id")) {
JSObject notificationJson = new JSObject();
JSObject dataObject = new JSObject();
for (String key : bundle.keySet()) {
if (key.equals("google.message_id")) {
notificationJson.put("id", bundle.get(key));
} else {
Object value = bundle.get(key);
String valueStr = (value != null) ? value.toString() : null;
dataObject.put(key, valueStr);
}
}
notificationJson.put("data", dataObject);
JSObject actionJson = new JSObject();
actionJson.put("actionId", "tap");
actionJson.put("notification", notificationJson);
notifyListeners("pushNotificationActionPerformed", actionJson, true);
}
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class DialogPlugin method confirm.
@PluginMethod
public void confirm(final PluginCall call) {
final AppCompatActivity activity = this.getActivity();
final String title = call.getString("title");
final String message = call.getString("message");
final String okButtonTitle = call.getString("okButtonTitle", "OK");
final String cancelButtonTitle = call.getString("cancelButtonTitle", "Cancel");
if (title == null || message == null) {
call.reject("Please provide a title or message for the alert");
return;
}
if (activity.isFinishing()) {
call.reject("App is finishing");
return;
}
Dialog.confirm(activity, message, title, okButtonTitle, cancelButtonTitle, (value, didCancel, inputValue) -> {
JSObject ret = new JSObject();
ret.put("value", value);
call.resolve(ret);
});
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class ScreenReaderPlugin method isEnabled.
@SuppressWarnings("unused")
@PluginMethod
public void isEnabled(PluginCall call) {
JSObject ret = new JSObject();
ret.put("value", screenReader.isEnabled());
call.resolve(ret);
}
use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.
the class TextZoomPlugin method get.
@PluginMethod
public void get(final PluginCall call) {
mainHandler.post(() -> {
JSObject ret = new JSObject();
ret.put("value", textZoom.get());
call.resolve(ret);
});
}
Aggregations