use of com.facebook.share.model.AppInviteContent in project react-native-fbsdk by facebook.
the class FBAppInviteDialogModule method show.
/**
* Helper to show the provided {@link com.facebook.share.model.AppInviteContent}.
* @param appInviteContentMap must be a valid {@link AppInviteContent}
* @param promise Use promise to pass the app invite dialog result to JS.
*/
@ReactMethod
public void show(ReadableMap appInviteContentMap, Promise promise) {
if (getCurrentActivity() != null) {
AppInviteDialog appInviteDialog = new AppInviteDialog(getCurrentActivity());
AppInviteContent appInviteContent = Utility.buildAppInviteContent(appInviteContentMap);
appInviteDialog.registerCallback(getCallbackManager(), new AppInviteDialogCallback(promise));
appInviteDialog.show(appInviteContent);
} else {
promise.reject("No current activity.");
}
}
use of com.facebook.share.model.AppInviteContent in project CodenameOne by codenameone.
the class FacebookImpl method inviteFriends.
@Override
public void inviteFriends(String appLinkUrl, String previewImageUrl, final Callback cb) {
if (AndroidNativeUtil.getActivity() == null) {
throw new RuntimeException("Cannot invite friends while running in the background.");
}
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder().setApplinkUrl(appLinkUrl).setPreviewImageUrl(previewImageUrl).build();
final CodenameOneActivity activity = (CodenameOneActivity) AndroidNativeUtil.getActivity();
if (cb == null) {
AppInviteDialog.show(activity, content);
} else {
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
final CallbackManager mCallbackManager = CallbackManager.Factory.create();
activity.setIntentResultListener(new IntentResultListener() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
activity.restoreIntentResultListener();
}
});
appInviteDialog.registerCallback(mCallbackManager, new FacebookCallback<AppInviteDialog.Result>() {
@Override
public void onSuccess(AppInviteDialog.Result result) {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onSucess(null);
}
});
}
@Override
public void onCancel() {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onError(null, null, -1, "User Cancelled");
}
});
}
@Override
public void onError(final FacebookException e) {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onError(null, e, 0, e.getMessage());
}
});
}
});
appInviteDialog.show(content);
}
}
}
Aggregations