Unable to get Facebook Publish Permission - Android - android

I am trying to get the publish_actions permission from the user for my app. The user has already logged in through facebook and in that instance I asked for some read permissions that the app needs. Getting the read permissions worked fine but there seems to be some problem with publish_actions. My code is:
private void asktopublish() {
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Toast.makeText(getApplicationContext(), "Done", Toast.LENGTH_LONG);
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
}
});
}
When the user clicks the button on my to grant the permission, the Facebook activity opens but closes almost instantly and seems to be empty as well.
I've tried looking for other solutions online but they all use the older fb sdk.

As #MBat suggested, I added the user as a tester and it works

Related

facebook image sharing using facebook api not working with other account in android

In my current project I've on task that is image sharing from our app to facebook. I've created project in my developer's account also.
In my app image sharing working with developers account. And I've made my developers account as public. Login is working but sharing is not working.
For every time it's going oncancel method in registerCallback.
callbackManager = CallbackManager.Factory.create();
List<String> permissionNeeds = Arrays.asList("publish_actions");
//this loginManager helps you eliminate adding a LoginButton to your UI
manager = LoginManager.getInstance();
manager.setLoginBehavior(LoginBehavior.WEB_ONLY);
manager.logInWithPublishPermissions(this, permissionNeeds);
manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
sharePhotoToFacebook();
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception) {
System.out.println("onError");
}
});
In case of sharing anything to facebook you need to submit your app to facebook for review.
check this for more.
Here is the whole guideline for app review process.

android app integration with facebook review compulsory?

I have written a code to login using facebook button sdk 4.0. I am able to login/logout. There is an activity for user from where user can share their locally saved picture to facebook. Sharing is possible if native facebook app is installed. But not in case facebook is not installed. So I tried to use ShareApi for sharing pictures via web view. But it requires publish actions permission. So I just written following code to get permission. It opens a window where it ask for per ok and cancel with my app name. After pressing ok button it always falls in onCancel case automatically.
I have read somewhere that you need to submit your app for review to facebook team in order to take publish actions permission. Is this only reason i am not getting success after trying almost 18 hours.?? Please help me friends.
List<String> permissionNeeds = Arrays.asList("publish_actions");
LoginManager loginManager = LoginManager.getInstance();
loginManager.logInWithPublishPermissions(activity,permissionNeeds);
loginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
System.out.println("onSuccess" + loginResult);
sharePhotoToFacebook();
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException error) {
System.out.println("onError"+error);
}
});

How to make a post or share button on Facebook in android

Facebook just driving me crazy! I have no idea, what they are trying to get from me. The thing is that I want to is to make SHARE button inside my Android app. What code I should write in order to get similar window?
This is the pic what I wanna do:
http://s29.postimg.org/pvgbhv1dz/151020_0002.png
This is the code how I do it now:
case FB_ID:
FacebookSdk.sdkInitialize(getApplicationContext());
fbCallbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
LoginManager.getInstance().registerCallback(fbCallbackManager,
new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Log.d(TAG, "FB");
openFragment(MakeWallPostFragment.newInstance(social_id,null), false);
// App code
}
#Override
public void onCancel() {
// App code
finish();
}
#Override
public void onError(FacebookException exception) {
// App code
}
});
break;
This code give me this kind of error:
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions")); //this is the culprit string gives me:
The publish_actions permissions are missing,
the share will fail unless this app was authorized to publish in another installation. this error
What should I use to make it happen?
Btw, this is the video with explanation, but I think all this stuff is deprecated now:http://www.youtube.com/watch?v=iBBVkwBeaY4

Can't request permissions from Android Facebook SDK

I'm attempting to request certain permissions when I log in to Facebook using the Android SDK. Using the following code, the login is successful, but the permissions I wanted are neither granted nor declined. It appears they were not even requested. What's wrong?
login_button.setReadPermissions(Arrays.asList("user_photos"));
login_button.setFragment(this);
LoginManager.getInstance().registerCallback(PicTag.callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.v(PicTag.TAG, "Facebook login success: " + loginResult.toString());
Log.v(PicTag.TAG, AccessToken.getCurrentAccessToken().getPermissions().toString());
Log.v(PicTag.TAG, loginResult.getRecentlyGrantedPermissions().toString());
if (shareFrag!=null){
shareFrag.shareContent();
activity.getSupportFragmentManager().popBackStackImmediate();
}
}
#Override
public void onCancel() {
// App code
Log.v(PicTag.TAG, "Facebook login canceled");
}
#Override
public void onError(FacebookException exception) {
// App code
Log.v(PicTag.TAG, "Facebook login error: " + exception.toString());
if (shareFrag!=null){
activity.getSupportFragmentManager().popBackStackImmediate();
}
}
});
}
According to "user_photos" Permissions documentation:
If your app requests this permission Facebook will have to review how your app uses it.
This is a new Facebook policy and you will most likely need to sumbit you application for Login Review.

Facebook SDK 4.x, setReadPermissions and setPublishPermissions

I had source code:
List<String> listPermission = Arrays.asList("email", "public_profile", "user_friends", "read_page_mailboxes", "read_insights");
List<String> listPermissionPublish = Arrays.asList("manage_pages", "publish_actions");
loginButton.setReadPermissions(listPermission);
loginButton.setPublishPermissions(listPermissionPublish);
loginButton.registerCallback(((HomeActivity) getActivity()).getCallbackManager(), new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
// App code
}
#Override
public void onCancel() {
// App code
}
#Override
public void onError(FacebookException exception) {
// App code
}
});
I using Facebook SDK 4.0 for Android.
But i had a problem getReadPermission and getPublishPermission on one request.
I see in: Get Read and Publish Permissions in one request
However in Facebook SDK 4.x is Session Removed.
Thanks for watching.
You can not ask for both permissions simultaneously. First get read permission and then ask for publish permission. I am calling this method from a button listener.
void requestPublishPermissions() {
// Requesting publish permissions
LoginManager.getInstance().logInWithReadPermissions(
this,
Arrays.asList("user_managed_groups", "user_groups"));
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
}

Categories

Resources