use of com.facebook.login.DefaultAudience in project facebook-android-sdk by facebook.
the class FacebookLoginActivity method onActivityResult.
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_PERMS_REQUEST) {
if (resultCode == RESULT_OK) {
String[] readPermsArr = data.getStringArrayExtra(PermissionSelectActivity.EXTRA_SELECTED_READ_PARAMS);
String writePrivacy = data.getStringExtra(PermissionSelectActivity.EXTRA_SELECTED_WRITE_PRIVACY);
String[] publishPermsArr = data.getStringArrayExtra(PermissionSelectActivity.EXTRA_SELECTED_PUBLISH_PARAMS);
fbLoginButton.clearPermissions();
if (readPermsArr != null) {
if (readPermsArr.length > 0) {
fbLoginButton.setReadPermissions(readPermsArr);
}
}
if ((readPermsArr == null || readPermsArr.length == 0) && publishPermsArr != null) {
if (publishPermsArr.length > 0) {
fbLoginButton.setPublishPermissions(publishPermsArr);
}
}
// Set write privacy for the user
if ((writePrivacy != null)) {
DefaultAudience audience;
if (DefaultAudience.EVERYONE.toString().equals(writePrivacy)) {
audience = DefaultAudience.EVERYONE;
} else if (DefaultAudience.FRIENDS.toString().equals(writePrivacy)) {
audience = DefaultAudience.FRIENDS;
} else {
audience = DefaultAudience.ONLY_ME;
}
fbLoginButton.setDefaultAudience(audience);
}
}
} else {
callbackManager.onActivityResult(requestCode, resultCode, data);
}
}
use of com.facebook.login.DefaultAudience in project react-native-fbsdk by facebook.
the class FBLoginManagerModule method setDefaultAudience.
/**
* Set {@link DefaultAudience} to use for sessions that post data to Facebook.
* @param defaultAudienceString must be one of the constants in Enum {@link DefaultAudience}.
* @throws {@link java.lang.IllegalArgumentException} if the argument is not a valid constant.
*/
@ReactMethod
public void setDefaultAudience(String defaultAudienceString) {
DefaultAudience defaultAudience = DefaultAudience.valueOf(defaultAudienceString.toUpperCase());
LoginManager.getInstance().setDefaultAudience(defaultAudience);
}
use of com.facebook.login.DefaultAudience in project facebook-android-sdk by facebook.
the class WebLoginMethodHandler method getParameters.
protected Bundle getParameters(final LoginClient.Request request) {
Bundle parameters = new Bundle();
if (!Utility.isNullOrEmpty(request.getPermissions())) {
String scope = TextUtils.join(",", request.getPermissions());
parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
}
DefaultAudience audience = request.getDefaultAudience();
parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());
parameters.putString(ServerProtocol.DIALOG_PARAM_STATE, getClientState(request.getAuthId()));
AccessToken previousToken = AccessToken.getCurrentAccessToken();
String previousTokenString = previousToken != null ? previousToken.getToken() : null;
if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) {
parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString);
// Don't log the actual access token, just its presence or absence.
addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES);
} else {
// The call to clear cookies will create the first instance of CookieSyncManager if
// necessary
Utility.clearFacebookCookies(loginClient.getActivity());
addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO);
}
return parameters;
}
Aggregations