Search in sources :

Example 46 with PluginMethod

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

the class PushNotificationsPlugin method register.

@PluginMethod
public void register(PluginCall call) {
    FirebaseMessaging.getInstance().setAutoInitEnabled(true);
    FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() {

        @Override
        public void onSuccess(InstanceIdResult instanceIdResult) {
            sendToken(instanceIdResult.getToken());
        }
    });
    FirebaseInstanceId.getInstance().getInstanceId().addOnFailureListener(new OnFailureListener() {

        public void onFailure(Exception e) {
            sendError(e.getLocalizedMessage());
        }
    });
    call.resolve();
}
Also used : InstanceIdResult(com.google.firebase.iid.InstanceIdResult) OnFailureListener(com.google.android.gms.tasks.OnFailureListener) JSONException(org.json.JSONException) PluginMethod(com.getcapacitor.PluginMethod)

Example 47 with PluginMethod

use of com.getcapacitor.PluginMethod 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);
    });
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 48 with PluginMethod

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

Example 49 with PluginMethod

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

Example 50 with PluginMethod

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

the class StatusBarPlugin method getInfo.

@PluginMethod
public void getInfo(final PluginCall call) {
    StatusBarInfo info = implementation.getInfo();
    JSObject data = new JSObject();
    data.put("visible", info.isVisible());
    data.put("style", info.getStyle());
    data.put("color", info.getColor());
    data.put("overlays", info.isOverlays());
    call.resolve(data);
}
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