@com.getcapacitor.PluginMethod

Here are the examples of the java api @com.getcapacitor.PluginMethod taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

77 Examples 7

19 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void stopAllPlayers(final PluginCall call) {
    saveCall(call);
    bridge.getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            if (fsFragment != null)
                fsFragment.pause();
            JSObject ret = new JSObject();
            ret.put("result", true);
            ret.put("method", "stopAllPlayers");
            ret.put("value", true);
            call.success(ret);
        }
    });
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will adjust volume to specified value
 * @param call
 */
@PluginMethod
public void setVolume(PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    if (!call.hasOption(VOLUME)) {
        call.error(VOLUME + " property is missing");
        return;
    }
    try {
        initSoundPool();
        String audioId = call.getString(replacedET_ID);
        float volume = call.getFloat(VOLUME);
        if (!audioreplacedetList.containsKey(audioId)) {
            call.error(audioId + " replacedet is not loaded");
            return;
        }
        Audioreplacedet replacedet = audioreplacedetList.get(audioId);
        if (replacedet != null) {
            replacedet.setVolume(volume);
        }
    } catch (Exception ex) {
        call.error(ex.getMessage());
    }
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will load short duration audio file into memory.
 * @param call
 */
@PluginMethod
public void preloadSimple(final PluginCall call) {
    if (!call.hasOption(replacedET_PATH)) {
        call.error(replacedET_PATH + " property is missing");
        return;
    }
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    new Thread(new Runnable() {

        @Override
        public void run() {
            preloadreplacedet(call);
        }
    }).start();
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will play the loaded audio file if present in the memory.
 * @param call
 */
@PluginMethod
public void play(final PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    getBridge().getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            playOrLoop("play", call);
        }
    });
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will resume the audio file during playback.
 * @param call
 */
@PluginMethod
public void resume(PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    try {
        initSoundPool();
        String audioId = call.getString(replacedET_ID);
        if (!audioreplacedetList.containsKey(audioId)) {
            call.error(audioId + " replacedet is not loaded");
            return;
        }
        Audioreplacedet replacedet = audioreplacedetList.get(audioId);
        if (replacedet != null) {
            replacedet.resume();
            resumeList.add(replacedet);
        }
    } catch (Exception ex) {
        call.error(ex.getMessage());
    }
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will loop the audio file for playback.
 * @param call
 */
@PluginMethod
public void loop(final PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    getBridge().getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            playOrLoop("loop", call);
        }
    });
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will stop the audio file during playback.
 * @param call
 */
@PluginMethod
public void stop(PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    try {
        initSoundPool();
        String audioId = call.getString(replacedET_ID);
        if (!audioreplacedetList.containsKey(audioId)) {
            call.error(audioId + " replacedet is not loaded");
            return;
        }
        Audioreplacedet replacedet = audioreplacedetList.get(audioId);
        if (replacedet != null) {
            replacedet.stop();
        }
    } catch (Exception ex) {
        call.error(ex.getMessage());
    }
}

19 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will load more optimized audio files for background into memory.
 * @param call
 */
@PluginMethod
public void preloadComplex(final PluginCall call) {
    if (!call.hasOption(replacedET_PATH)) {
        call.error(replacedET_PATH + " property is missing");
        return;
    }
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    new Thread(new Runnable() {

        @Override
        public void run() {
            preloadreplacedet(call);
        }
    }).start();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void prepare(PluginCall call) {
    prepare();
    call.resolve();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void stopScan(PluginCall call) {
    destroy();
    call.resolve();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void hideBackground(PluginCall call) {
    hideBackground();
    call.resolve();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void checkPermission(PluginCall call) {
    Boolean force = call.getBoolean("force", false);
    _checkPermission(call, force);
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void showBackground(PluginCall call) {
    showBackground();
    call.resolve();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void openAppSettings(PluginCall call) {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getAppId(), null));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(call, intent, RESULT_CODE);
    call.resolve();
}

19 Source : BarcodeScanner.java
with MIT License
from capacitor-community

@PluginMethod
public void startScan(PluginCall call) {
    saveCall(call);
    scan();
}

19 Source : AdMob.java
with MIT License
from capacitor-community

@PluginMethod
public void resumeRewardedVideo(final PluginCall call) {
    adRewardExecutor.resumeRewardedVideo(call);
}

19 Source : AdMob.java
with MIT License
from capacitor-community

@PluginMethod
public void pauseRewardedVideo(final PluginCall call) {
    adRewardExecutor.pauseRewardedVideo(call);
}

19 Source : AdMob.java
with MIT License
from capacitor-community

// Show intersreplacedial Ad
@PluginMethod
public void showIntersreplacedial(final PluginCall call) {
    try {
        getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (mIntersreplacedialAd != null && mIntersreplacedialAd.isLoaded()) {
                    getActivity().runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            mIntersreplacedialAd.show();
                        }
                    });
                    call.success(new JSObject().put("value", true));
                } else {
                    call.error("The intersreplacedial wasn't loaded yet.");
                }
            }
        });
    } catch (Exception ex) {
        call.error(ex.getLocalizedMessage(), ex);
    }
}

19 Source : AdMob.java
with MIT License
from capacitor-community

// Destroy the banner, remove it from screen.
@PluginMethod
public void removeBanner(final PluginCall call) {
    bannerExecutor.removeBanner(call);
}

19 Source : AdMob.java
with MIT License
from capacitor-community

// Resume the banner, show it after hide
@PluginMethod
public void resumeBanner(final PluginCall call) {
    bannerExecutor.resumeBanner(call);
}

19 Source : AdMob.java
with MIT License
from capacitor-community

@PluginMethod
public void showRewardVideoAd(final PluginCall call) {
    adRewardExecutor.showRewardVideoAd(call);
}

19 Source : AdMob.java
with MIT License
from capacitor-community

@PluginMethod
public void prepareRewardVideoAd(final PluginCall call) {
    adRewardExecutor.prepareRewardVideoAd(call, this::notifyListeners);
}

19 Source : AdMobPlusPlugin.java
with MIT License
from admob-plus

@PluginMethod
public void bannerShow(PluginCall call) {
    final BannerAd bannerAd = BannerAd.getOrCreate(call);
    final AdRequest adRequest = new AdRequest.Builder().build();
    getBridge().executeOnMainThread(() -> {
        bannerAd.show(this, call, adRequest);
    });
}

19 Source : AdMobPlusPlugin.java
with MIT License
from admob-plus

@PluginMethod
public void bannerHide(PluginCall call) {
    Integer id = call.getInt("id");
    final BannerAd bannerAd = (BannerAd) AdBase.getAd(id);
    if (bannerAd == null) {
        call.reject("Invalid options");
        return;
    }
    getBridge().executeOnMainThread(() -> {
        bannerAd.hide(this, call);
    });
}

19 Source : AdMobPlusPlugin.java
with MIT License
from admob-plus

@PluginMethod
public void start(PluginCall call) {
    MobileAds.initialize(getContext(), new OnInitializationCompleteListener() {

        @Override
        public void onInitializationComplete(InitializationStatus status) {
            call.resolve();
        }
    });
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void pause(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "pause");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                fsFragment.pause();
                JSObject data = new JSObject();
                data.put("result", true);
                data.put("method", "pause");
                data.put("value", true);
                call.success(data);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void setMuted(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "setMuted");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    Boolean value = call.getBoolean("muted");
    if (value == null) {
        ret.put("result", true);
        ret.put("message", "Must provide a boolean true/false");
        call.success(ret);
        return;
    }
    final boolean bValue = value;
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                fsFragment.setMuted(bValue);
                JSObject ret = new JSObject();
                ret.put("result", true);
                ret.put("method", "setMuted");
                ret.put("value", bValue);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void setVolume(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "setVolume");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    String value = call.getString("volume");
    if (value == null) {
        ret.put("result", false);
        ret.put("method", "setVolume");
        ret.put("message", "Must provide a volume value");
        call.success(ret);
        return;
    }
    final Float volume = Float.valueOf(value.trim());
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                fsFragment.setVolume(volume);
                JSObject ret = new JSObject();
                ret.put("result", true);
                ret.put("method", "setVolume");
                ret.put("value", volume);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void isPlaying(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "isPlaying");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                boolean playing = fsFragment.isPlaying();
                JSObject data = new JSObject();
                data.put("result", true);
                data.put("method", "isPlaying");
                data.put("value", playing);
                call.success(data);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void getVolume(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "getVolume");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                Float volume = fsFragment.getVolume();
                JSObject ret = new JSObject();
                ret.put("result", true);
                ret.put("method", "getVolume");
                ret.put("value", volume);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void getDuration(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "getDuration");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                JSObject ret = new JSObject();
                ret.put("method", "getDuration");
                int duration = fsFragment.getDuration();
                ret.put("result", true);
                ret.put("value", duration);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void getMuted(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "getMuted");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                boolean value = fsFragment.getMuted();
                JSObject ret = new JSObject();
                ret.put("result", true);
                ret.put("method", "getMuted");
                ret.put("value", value);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void echo(PluginCall call) {
    String value = call.getString("value");
    JSObject ret = new JSObject();
    ret.put("value", value);
    call.success(ret);
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void play(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "play");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                fsFragment.play();
                boolean playing = fsFragment.isPlaying();
                JSObject data = new JSObject();
                data.put("result", true);
                data.put("method", "play");
                data.put("value", true);
                call.success(data);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : CapacitorVideoPlayer.java
with MIT License
from jepiqueau

@PluginMethod
public void getCurrentTime(final PluginCall call) {
    saveCall(call);
    JSObject ret = new JSObject();
    ret.put("method", "getCurrentTime");
    String playerId = call.getString("playerId");
    if (playerId == null) {
        ret.put("result", false);
        ret.put("message", "Must provide a PlayerId");
        call.success(ret);
        return;
    }
    if (mode.equals("fullscreen") && fsPlayerId.equals(playerId)) {
        bridge.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                JSObject ret = new JSObject();
                ret.put("method", "getCurrentTime");
                int curTime = fsFragment.getCurrentTime();
                ret.put("result", true);
                ret.put("value", curTime);
                call.success(ret);
            }
        });
    } else {
        ret.put("result", false);
        ret.put("message", "player is not defined");
        call.success(ret);
    }
}

18 Source : Permissions.java
with MIT License
from DoFabien

@PluginMethod
public void query(PluginCall call) {
    String name = call.getString("name");
    switch(name) {
        case "camera":
            checkCamera(call);
            break;
        case "photos":
            checkPhotos(call);
            break;
        case "geolocation":
            checkGeo(call);
            break;
        case "notifications":
            checkNotifications(call);
            break;
        case "clipboard-read":
        case "clipboard-write":
            checkClipboard(call);
            break;
        default:
            call.reject("Unknown permission type");
    }
}

18 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will pause the audio file during playback.
 * @param call
 */
@PluginMethod
public void pause(PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    try {
        initSoundPool();
        String audioId = call.getString(replacedET_ID);
        if (!audioreplacedetList.containsKey(audioId)) {
            call.error(audioId + " replacedet is not loaded");
            return;
        }
        Audioreplacedet replacedet = audioreplacedetList.get(audioId);
        if (replacedet != null) {
            boolean wasPlaying = replacedet.pause();
            if (wasPlaying) {
                resumeList.add(replacedet);
            }
        }
        call.success();
    } catch (Exception ex) {
        call.error(ex.getMessage());
    }
}

18 Source : NativeAudio.java
with MIT License
from capacitor-community

/**
 * This method will stop and unload the audio file.
 * @param call
 */
@PluginMethod
public void unload(PluginCall call) {
    if (!call.hasOption(replacedET_ID)) {
        call.error(replacedET_ID + " property is missing");
        return;
    }
    try {
        initSoundPool();
        new JSObject();
        JSObject status;
        String audioId = call.getString(replacedET_ID);
        if (!audioreplacedetList.containsKey(audioId)) {
            call.error(audioId + " replacedet is not loaded");
            return;
        }
        Audioreplacedet replacedet = audioreplacedetList.get(audioId);
        if (replacedet != null) {
            replacedet.stop();
            replacedet.unload();
            audioreplacedetList.remove(audioId);
        }
        call.success();
    } catch (Exception ex) {
        call.error(ex.getMessage());
    }
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Adds logging that is sent with your crash data. The logging does not appear in the system.log and is only visible in the Crashlytics dashboard.
 * @param call - message: message - message to display during logging
 */
@PluginMethod
public void addLogMessage(PluginCall call) {
    if (!call.hasOption("message")) {
        call.error("message property is missing");
        return;
    }
    String message = call.getString("message");
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().log(message);
    call.success();
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Indicates whether or not automatic data collection is enabled
 * @param call
 * @return enabled: boolean true/false
 */
@PluginMethod
public void isEnabled(PluginCall call) {
    call.success(new JSObject().put("enabled", false));
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Records a non-fatal report to send to Crashlytics.
 * If automatic data collection is disabled, this method queues up all the reports on a device to send to Crashlytics.
 * @param call
 */
@PluginMethod
public void recordException(PluginCall call) {
    if (!call.hasOption("message")) {
        call.error("message property is missing");
        return;
    }
    String message = call.getString("message");
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().recordException(new Throwable(message));
    call.success();
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Enqueues any unsent reports on the device to upload to Crashlytics.
 * This method only applies if automatic data collection is disabled.
 * @param call
 */
@PluginMethod
public void sendUnsentReports(PluginCall call) {
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().sendUnsentReports();
    call.success();
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Deletes any unsent reports on the device.
 * This method only applies if automatic data collection is disabled.
 * @param call
 */
@PluginMethod
public void deleteUnsentReports(PluginCall call) {
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().deleteUnsentReports();
    call.success();
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Enables/disables automatic data collection.
 * @param call - enabled: boolean true/false to enable/disable crashlytics logging
 */
@PluginMethod
public void setEnabled(PluginCall call) {
    Boolean enabled = call.getBoolean("enabled", false);
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled);
    call.success();
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Trigger a fatal crash for crashlytics to record
 * @param call
 */
@PluginMethod
public void crash(PluginCall call) {
    if (!call.hasOption("message")) {
        call.error("message property is missing");
        return;
    }
    String message = call.getString("message");
    call.success();
    throw new RuntimeException(message);
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Returns whether the app crashed during the previous execution.
 * @param call
 * @return crashed: boolean true/false
 */
@PluginMethod
public void didCrashOnPreviousExecution(PluginCall call) {
    call.success(new JSObject().put("crashed", com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().didCrashOnPreviousExecution()));
}

18 Source : FirebaseCrashlytics.java
with MIT License
from capacitor-community

/**
 * Records a user ID (identifier) that’s replacedociated with subsequent fatal and non-fatal reports.
 * @param call - userId: unique user identifier
 */
@PluginMethod
public void setUserId(PluginCall call) {
    if (!call.hasOption("userId")) {
        call.error("userId is missing");
        return;
    }
    String userId = call.getString("userId");
    com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setUserId(userId);
    call.success();
}

18 Source : FacebookLogin.java
with MIT License
from capacitor-community

@PluginMethod
public void login(PluginCall call) {
    Log.d(getLogTag(), "Entering login()");
    PluginCall savedCall = getSavedCall();
    if (savedCall != null) {
        Log.e(getLogTag(), "login: overlapped calls not supported");
        call.reject("Overlapped calls call not supported");
        return;
    }
    JSArray arg = call.getArray("permissions");
    Collection<String> permissions;
    try {
        permissions = arg.toList();
    } catch (Exception e) {
        Log.e(getLogTag(), "login: invalid 'permissions' argument", e);
        call.reject("Invalid permissions argument");
        return;
    }
    LoginManager.getInstance().logInWithReadPermissions(this.getActivity(), permissions);
    saveCall(call);
}

18 Source : FacebookLogin.java
with MIT License
from capacitor-community

@PluginMethod
public void logout(PluginCall call) {
    Log.d(getLogTag(), "Entering logout()");
    LoginManager.getInstance().logOut();
    call.success();
}

18 Source : FacebookLogin.java
with MIT License
from capacitor-community

@PluginMethod
public void getCurrentAccessToken(PluginCall call) {
    Log.d(getLogTag(), "Entering getCurrentAccessToken()");
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    JSObject ret = new JSObject();
    if (accessToken == null) {
        Log.d(getLogTag(), "getCurrentAccessToken: accessToken is null");
    } else {
        Log.d(getLogTag(), "getCurrentAccessToken: accessToken found");
        ret.put("accessToken", accessTokenToJson(accessToken));
    }
    call.success(ret);
}

See More Examples