use of com.facebook.share.widget.AppInviteDialog 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.widget.AppInviteDialog in project facebook-android-sdk by facebook.
the class RpsFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
wins = savedInstanceState.getInt(WIN_KEY);
losses = savedInstanceState.getInt(LOSS_KEY);
ties = savedInstanceState.getInt(TIE_KEY);
computerChoice = savedInstanceState.getInt(COMPUTER_CHOICE_KEY);
playerChoice = savedInstanceState.getInt(PLAYER_CHOICE_KEY);
currentState = (RpsState) savedInstanceState.getSerializable(STATE_KEY);
result = (RpsResult) savedInstanceState.getSerializable(RESULT_KEY);
pendingPublish = savedInstanceState.getBoolean(PENDING_PUBLISH_KEY);
shouldImplicitlyPublish = savedInstanceState.getBoolean(IMPLICIT_PUBLISH_KEY);
}
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken.getPermissions().contains(ADDITIONAL_PERMISSIONS)) {
publishResult();
} else {
handleError();
}
}
@Override
public void onCancel() {
handleError();
}
@Override
public void onError(FacebookException exception) {
handleError();
}
private void handleError() {
// this means the user did not grant us write permissions, so
// we don't do implicit publishes
shouldImplicitlyPublish = false;
pendingPublish = false;
}
});
FacebookCallback<Sharer.Result> callback = new FacebookCallback<Sharer.Result>() {
@Override
public void onCancel() {
Log.d(TAG, "Canceled");
}
@Override
public void onError(FacebookException error) {
Log.d(TAG, String.format("Error: %s", error.toString()));
}
@Override
public void onSuccess(Sharer.Result result) {
Log.d(TAG, "Success!");
}
};
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, callback);
messageDialog = new MessageDialog(this);
messageDialog.registerCallback(callbackManager, callback);
FacebookCallback<AppInviteDialog.Result> appInviteCallback = new FacebookCallback<AppInviteDialog.Result>() {
@Override
public void onSuccess(AppInviteDialog.Result result) {
Log.d(TAG, "Success!");
}
@Override
public void onCancel() {
Log.d(TAG, "Canceled");
}
@Override
public void onError(FacebookException error) {
Log.d(TAG, String.format("Error: %s", error.toString()));
}
};
appInviteDialog = new AppInviteDialog(this);
appInviteDialog.registerCallback(callbackManager, appInviteCallback);
}
Aggregations