User has to click the post button in the share dialog every time they complete a level.I need to eliminate this hardship for user. As of now I have created a custom story and requesting user to click post every time.
Question :
I heard of frictionless FB post for the Open graph stories. Is it possible in android ?
If frictionless FB post is available in android, could you please point be the correction in my code that I have pasted below.
If frictionless FB post is available in android, What is the permission that I need to get from user ?
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "puzzlegameballmania:level")
.putString("og:title", "Cleared Level-1 !!!")
.putString("og:image", "http://ixxxxwsz.jpg")
.putString("og:url", "https://play.google.com/store/apps/details?id=com.gamxxxxx.android")
.putString("og:description", "Color of the balls matters more. Lets break the goal and go higher !")
.putString("puzzlegameballmania:level:title", "LEVEL 1")
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("puzzlegameballmania:clear")
.putObject("puzzlegameballmania:level", object)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("puzzlegameballmania:level")
.setAction(action)
.build();
ShareDialog.show(AndroidLauncher.this, content);
ShareDialog
, instead use ShareApi, here's some sample code
You may also want to read this Facebook developer post, which seem to discourage implicit/automated posting. A warning to the user is displayed if the app has not been reviewed.
Edit
Before using ShareApi
, first check to see if the app has the required permission:
private boolean hasPublishPermission() {
AccessToken accessToken = AccessToken.getCurrentAccessToken();
return accessToken != null && accessToken.getPermissions().contains("publish_actions");
}
If not, execute code below to request the permission:
LoginManager.getInstance().logInWithPublishPermissions(
this, Arrays.asList("publish_actions"));
If you use ShareApi without the proper permission, it will fail and onError(FacebookException)
method will be called, assuming you have passed a FacebookCallback to ShareApi
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With