Search in sources :

Example 1 with ShareContent

use of com.facebook.share.model.ShareContent in project react-native-fbsdk by facebook.

the class FBMessageDialogModule method canShow.

/**
     * Indicates whether it is possible to show the dialog for ShareContent of the specified type.
     * @param shareContentMap  must be a valid {@link ShareContent}.
     * @param promise Use promise to pass message dialog result to JS.
     */
@ReactMethod
public void canShow(ReadableMap shareContentMap, Promise promise) {
    if (getCurrentActivity() != null) {
        ShareContent shareContent = Utility.buildShareContent(shareContentMap);
        MessageDialog messageDialog = new MessageDialog(getCurrentActivity());
        promise.resolve(messageDialog.canShow(shareContent));
    } else {
        promise.reject("No current activity.");
    }
}
Also used : MessageDialog(com.facebook.share.widget.MessageDialog) ShareContent(com.facebook.share.model.ShareContent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 2 with ShareContent

use of com.facebook.share.model.ShareContent in project facebook-android-sdk by facebook.

the class SelectionFragment method updateShareContent.

private void updateShareContent() {
    ShareContent content = createOpenGraphContent();
    if (content != null) {
        enableButtons();
    } else {
        disableButtons();
    }
    shareButton.setShareContent(content);
    messageButton.setShareContent(content);
}
Also used : ShareContent(com.facebook.share.model.ShareContent)

Example 3 with ShareContent

use of com.facebook.share.model.ShareContent in project react-native-fbsdk by facebook.

the class FBMessageDialogModule method show.

/**
     * Show the provided ShareContent using the provided Activity.
     * @param shareContentMap  must be a valid {@link ShareContent}.
     * @param promise Use promise to pass message dialog result to JS.
     */
@ReactMethod
public void show(ReadableMap shareContentMap, Promise promise) {
    if (getCurrentActivity() != null) {
        ShareContent shareContent = Utility.buildShareContent(shareContentMap);
        MessageDialog messageDialog = new MessageDialog(getCurrentActivity());
        messageDialog.setShouldFailOnDataError(mShouldFailOnDataError);
        messageDialog.registerCallback(getCallbackManager(), new MessageDialogCallback(promise));
        messageDialog.show(shareContent);
    } else {
        promise.reject("No current activity.");
    }
}
Also used : MessageDialog(com.facebook.share.widget.MessageDialog) ShareContent(com.facebook.share.model.ShareContent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 4 with ShareContent

use of com.facebook.share.model.ShareContent in project react-native-fbsdk by facebook.

the class FBShareAPIModule method canShare.

/**
     * Check if the content can be shared.
     * @param shareContentMap must be a valid {@link ShareContent}
     * @param promise Use promise to pass the result to JS.
     */
@ReactMethod
public void canShare(ReadableMap shareContentMap, Promise promise) {
    ShareContent shareContent = Utility.buildShareContent(shareContentMap);
    if (shareContent != null) {
        ShareApi shareApi = new ShareApi(shareContent);
        promise.resolve(shareApi.canShare());
    } 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 5 with ShareContent

use of com.facebook.share.model.ShareContent 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)

Aggregations

ShareContent (com.facebook.share.model.ShareContent)6 ReactMethod (com.facebook.react.bridge.ReactMethod)4 ShareApi (com.facebook.share.ShareApi)2 MessageDialog (com.facebook.share.widget.MessageDialog)2 Intent (android.content.Intent)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FacebookDialogFragment (com.facebook.internal.FacebookDialogFragment)1 LoginFragment (com.facebook.login.LoginFragment)1 DeviceShareDialogFragment (com.facebook.share.internal.DeviceShareDialogFragment)1