Search in sources :

Example 41 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.

the class FBShareAPIModule method share.

/**
     * Share the content.
     * @param shareContentMap must be a valid {@link ShareContent}.
     * @param graphNode The graph node to share to (this can be a user id, event id, page id, group id, album
     * id, etc).
     * @param message The custom message that will accompany the share content.
     * @param promise Use promise to pass share api result to JS.
     */
@ReactMethod
public void share(ReadableMap shareContentMap, String graphNode, String message, Promise promise) {
    ShareContent shareContent = Utility.buildShareContent(shareContentMap);
    if (shareContent != null) {
        ShareApi shareApi = new ShareApi(shareContent);
        shareApi.setGraphNode(graphNode);
        shareApi.setMessage(message);
        shareApi.share(new ShareAPICallback(promise));
    } else {
        promise.reject("ShareContent cannot be null");
    }
}
Also used : ShareApi(com.facebook.share.ShareApi) ShareContent(com.facebook.share.model.ShareContent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 42 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.

the class FBLoginManagerModule method logInWithReadPermissions.

/**
     * Attempts a Facebook login with the specified read permissions.
     * @param permissions must be one of the provided read permissions. See
     *                    <a href="https://developers.facebook.com/docs/facebook-login/permissions">
     *                    Facebook login permissions</a>.
     * @param promise Use promise to pass login result to JS after login finish.
     */
@ReactMethod
public void logInWithReadPermissions(ReadableArray permissions, final Promise promise) {
    final LoginManager loginManager = LoginManager.getInstance();
    loginManager.registerCallback(mCallbackManager, new LoginManagerCallback(promise));
    Activity activity = getCurrentActivity();
    if (activity != null) {
        loginManager.logInWithReadPermissions(activity, reactArrayToJavaStringCollection(permissions));
    }
}
Also used : LoginManager(com.facebook.login.LoginManager) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 43 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-image-picker by marcshilling.

the class ImagePickerModule method launchImageLibrary.

// NOTE: Currently not reentrant / doesn't support concurrent requests
@ReactMethod
public void launchImageLibrary(final ReadableMap options, final Callback callback) {
    final Activity currentActivity = getCurrentActivity();
    if (currentActivity == null) {
        responseHelper.invokeError(callback, "can't find current Activity");
        return;
    }
    this.options = options;
    if (!permissionsCheck(currentActivity, callback, REQUEST_PERMISSIONS_FOR_LIBRARY)) {
        return;
    }
    parseOptions(this.options);
    int requestCode;
    Intent libraryIntent;
    if (pickVideo) {
        requestCode = REQUEST_LAUNCH_VIDEO_LIBRARY;
        libraryIntent = new Intent(Intent.ACTION_PICK);
        libraryIntent.setType("video/*");
    } else {
        requestCode = REQUEST_LAUNCH_IMAGE_LIBRARY;
        libraryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    if (libraryIntent.resolveActivity(reactContext.getPackageManager()) == null) {
        responseHelper.invokeError(callback, "Cannot launch photo library");
        return;
    }
    this.callback = callback;
    try {
        currentActivity.startActivityForResult(libraryIntent, requestCode);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        responseHelper.invokeError(callback, "Cannot launch photo library");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) ReactActivity(com.facebook.react.ReactActivity) Activity(android.app.Activity) Intent(android.content.Intent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 44 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-push-notification by zo0r.

the class RNPushNotification method scheduleLocalNotification.

@ReactMethod
public void scheduleLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    // If notification ID is not provided by the user, generate one at random
    if (bundle.getString("id") == null) {
        bundle.putString("id", String.valueOf(mRandomNumberGenerator.nextInt()));
    }
    mRNPushNotificationHelper.sendNotificationScheduled(bundle);
}
Also used : Bundle(android.os.Bundle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 45 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-navigation by wix.

the class NavigationReactModule method showLightBox.

@ReactMethod
public void showLightBox(final ReadableMap params) {
    LightBoxParams lbp = new LightBoxParamsParser(BundleConverter.toBundle(params)).parse();
    NavigationCommandsHandler.showLightBox(lbp);
}
Also used : LightBoxParamsParser(com.reactnativenavigation.params.parsers.LightBoxParamsParser) LightBoxParams(com.reactnativenavigation.params.LightBoxParams) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)82 Activity (android.app.Activity)21 Intent (android.content.Intent)11 WritableMap (com.facebook.react.bridge.WritableMap)11 Bundle (android.os.Bundle)9 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)6 WritableArray (com.facebook.react.bridge.WritableArray)6 ArrayList (java.util.ArrayList)5 Camera (android.hardware.Camera)4 NativeViewHierarchyManager (com.facebook.react.uimanager.NativeViewHierarchyManager)4 UIBlock (com.facebook.react.uimanager.UIBlock)4 UIManagerModule (com.facebook.react.uimanager.UIManagerModule)4 ShareContent (com.facebook.share.model.ShareContent)4 LayoutNode (com.reactnativenavigation.options.LayoutNode)4 LoginManager (com.facebook.login.LoginManager)3 ReactActivity (com.facebook.react.ReactActivity)3 LatLng (com.google.android.gms.maps.model.LatLng)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 RemoteException (android.os.RemoteException)2 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)2