Search in sources :

Example 56 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-plugins by ionic-team.

the class DevicePlugin method getInfo.

@PluginMethod
public void getInfo(PluginCall call) {
    JSObject r = new JSObject();
    r.put("memUsed", implementation.getMemUsed());
    r.put("diskFree", implementation.getDiskFree());
    r.put("diskTotal", implementation.getDiskTotal());
    r.put("realDiskFree", implementation.getRealDiskFree());
    r.put("realDiskTotal", implementation.getRealDiskTotal());
    r.put("model", android.os.Build.MODEL);
    r.put("operatingSystem", "android");
    r.put("osVersion", android.os.Build.VERSION.RELEASE);
    r.put("platform", implementation.getPlatform());
    r.put("manufacturer", android.os.Build.MANUFACTURER);
    r.put("isVirtual", implementation.isVirtual());
    r.put("name", implementation.getName());
    r.put("webViewVersion", implementation.getWebViewVersion());
    call.resolve(r);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 57 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-plugins by ionic-team.

the class AppPlugin method getState.

@PluginMethod
public void getState(PluginCall call) {
    JSObject data = new JSObject();
    data.put("isActive", this.bridge.getApp().isActive());
    call.resolve(data);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 58 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-plugins by ionic-team.

the class AppPlugin method getLaunchUrl.

@PluginMethod
public void getLaunchUrl(PluginCall call) {
    Uri launchUri = bridge.getIntentUri();
    if (launchUri != null) {
        JSObject d = new JSObject();
        d.put("url", launchUri.toString());
        call.resolve(d);
    } else {
        call.resolve();
    }
}
Also used : JSObject(com.getcapacitor.JSObject) Uri(android.net.Uri) PluginMethod(com.getcapacitor.PluginMethod)

Example 59 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method trackOnce.

@PluginMethod()
public void trackOnce(final PluginCall call) {
    Radar.RadarTrackCallback callback = new Radar.RadarTrackCallback() {

        @Override
        public void onComplete(@NotNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
            if (status == Radar.RadarStatus.SUCCESS && location != null && events != null && user != null) {
                JSObject ret = new JSObject();
                ret.put("status", status.toString());
                ret.put("location", RadarPlugin.jsObjectForJSONObject(Radar.jsonForLocation(location)));
                ret.put("events", RadarPlugin.jsArrayForJSONArray(RadarEvent.toJson(events)));
                ret.put("user", RadarPlugin.jsObjectForJSONObject(user.toJson()));
                call.resolve(ret);
            } else {
                call.reject(status.toString());
            }
        }
    };
    if (call.hasOption("latitude") && call.hasOption("longitude") && call.hasOption("accuracy")) {
        double latitude = call.getDouble("latitude");
        double longitude = call.getDouble("longitude");
        float accuracy = call.getDouble("accuracy").floatValue();
        Location location = new Location("RadarSDK");
        location.setLatitude(latitude);
        location.setLongitude(longitude);
        location.setAccuracy(accuracy);
        Radar.trackOnce(location, callback);
    } else {
        Radar.trackOnce(callback);
    }
}
Also used : RadarUser(io.radar.sdk.model.RadarUser) Radar(io.radar.sdk.Radar) JSObject(com.getcapacitor.JSObject) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) Location(android.location.Location) PluginMethod(com.getcapacitor.PluginMethod)

Example 60 with PluginMethod

use of com.getcapacitor.PluginMethod in project capacitor-radar by radarlabs.

the class RadarPlugin method setMetadata.

@PluginMethod()
public void setMetadata(PluginCall call) {
    JSObject metadata = call.getObject("metadata");
    Radar.setMetadata(RadarPlugin.jsonObjectForJSObject(metadata));
    call.resolve();
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Aggregations

PluginMethod (com.getcapacitor.PluginMethod)120 JSObject (com.getcapacitor.JSObject)93 JSONException (org.json.JSONException)18 MyRunnable (com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable)13 JSONObject (org.json.JSONObject)13 JSArray (com.getcapacitor.JSArray)12 Radar (io.radar.sdk.Radar)11 Location (android.location.Location)8 Intent (android.content.Intent)7 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 Uri (android.net.Uri)5 LatLng (com.google.android.libraries.maps.model.LatLng)5 GenericAd (admob.plus.core.GenericAd)4 GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)4 Gson (com.google.gson.Gson)4 PackageManager (android.content.pm.PackageManager)3 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)3 User (io.ionic.demo.ecommerce.data.model.User)3 Context (android.content.Context)2