Is incentivised sharing allowed / possible? - android

I would like to encourage user engagement in my app by rewarding them with a once off advantage (a kind of power-up I guess) when they share something on social media (twitter, Google+ or Facebook).
My first question is, is this considered acceptable by the Google Play store?
My next question (assuming the answer to my first is yes), is how to be sure the user has completed the share so I do not reward cancelled share intents?
My initial attempt has focussed on Facebook and I have set up the Facebook SDK, registered my App with Facebook and can complete a share, but as others have shown the share result is the same regardless of whether the user cancelled or posted. I note that similar questions have been asked here and here. But none of these have satisfactory solutions.
This answer sounds promising, but I don't recognise the "Session" type as part of the Facebook SDK .
My implementation at the moment uses this in a fragment in response to the user's button press:
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("My Title")
.setContentDescription("My Description.")
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.cloudforge.svn.bbarrett.floattiles"))
.build();
MainActivity.shareDialog.show(linkContent);
Then in my Main Activity I have the method:
#Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
I note from debug here that "resultCode" is -1 when the user cancels and when they post.
Finally in the MainActivity.onCreate() method I have:
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
// TODO Auto-generated method stub
if(result.getPostId()!=null){
Toast.makeText(getBaseContext(), "User posted! (but this is never called as postId is always null)", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getBaseContext(), "User didn't post? (but this is called even when they have posted as postId is always null)", Toast.LENGTH_LONG).show();
}
}
#Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "User Cancelled (but this is never called)", Toast.LENGTH_LONG).show();
}
#Override
public void onError(FacebookException error) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "Exception occurred", Toast.LENGTH_LONG).show();
}
});
I dont think my users will be particularly motivated to share unless they gain a game advantage from doing so, so I am really hoping someone can help me confirm a successful Facebook post (I'll deal with Google+ and twitter next!).
Thank you in advance for all reads, upvotes and answers.

Related

Check shared Post on Facebook Successfully or discarded

Facebook SDK always call onSuccess(Sharer.Result result) after discarding the post.
I am using the share post of the Facebook SDK, but always call onSuccess listener even after the discard or cancel the post.
I am using this facebook SDK for share the post implementation 'com.facebook.android:facebook-share:[4,5)'and use this doc.
https://developers.facebook.com/docs/sharing/android/
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Log.e(TAG, result.toString());
Toast.makeText(MainActivity.this, "shared succrssfull", Toast.LENGTH_SHORT).show();
}
#Override
public void onCancel() {
Toast.makeText(MainActivity.this, "shared cancel", Toast.LENGTH_SHORT).show();
}
#Override
public void onError(FacebookException error) {
Log.e(TAG, error.toString());
Toast.makeText(MainActivity.this, "shared error occured", Toast.LENGTH_SHORT).show();
}
});
and have onActivity Result is
#Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
but always called onSuccess listner , how can I find the post has been succesfully post.
have checked with multiple link but not got any solution yet so please help me out.
Post Id facebook share dialog always return null in Android
FB share dialog cancel callback not working in Android
we can not recognize the post has been successful or not because the policy has been given by Facebook.
Don't incentivize people to post content on Facebook or give the impression that posting to Facebook will be rewarded. For example, don’t give people anything in exchange for them posting to Facebook (i.e. don’t give or promise virtual goods, achievements, coupons, discounts, access to content or extra entries in a promotion, if they post content to Facebook).
the policy of Facebook has been given below.
https://developers.facebook.com/docs/apps/examples-platform-policy-4.5
https://developers.facebook.com/policy#properuse

How to Retrieve Login Callback from twitter webview using fabric

I am implementing twitter login using fabric, the login with native app seems fine. But when i am trying the login without twitter app installed in the device, it starts authorization with the webview, but on completion i didnt receive any callback neither in onSucccess or failure method
mTwitterAuthClient.authorize(ConnectSocialMedia.this, new Callback<com.twitter.sdk.android.core.TwitterSession>() {
#Override
public void success(Result<com.twitter.sdk.android.core.TwitterSession> result) {
// Success
mDialog.dismiss();
// The TwitterSession is also available through:
// Twitter.getInstance().core.getSessionManager().getActiveSession()
com.twitter.sdk.android.core.TwitterSession session = result.data;
ApplicationData.setSharedPrefValue(mActivity, "twittertoken", session.getAuthToken().token);
ApplicationData.setSharedPrefValue(mActivity, "twittertokensecret", session.getAuthToken().secret);
ApplicationData.setSharedPrefValue(mActivity, "twitterid", String.valueOf(session.getUserId()));
imgTwitter.setVisibility(View.VISIBLE);
mTwitterLoginButton.setEnabled(false);
btnClose.setVisibility(View.VISIBLE);
// getTwitterCover(String.valueOf(session.getUserId()));
}
#Override
public void failure(TwitterException e) {
mDialog.dismiss();
Log.d("TwitterKit", "Login with Twitter failure", e);
Toast.makeText(mActivity, "Twitter Login Failed", Toast.LENGTH_SHORT).show();
mTwitterLoginButton.setEnabled(true);
}
});
}
});
and neither on onActivityResult
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Make sure that the mTwitterLoginButton hears the result from any
// Activity that it triggered.
mTwitterAuthClient.onActivityResult(requestCode, resultCode, data);
}
Please help me, thanks
Add any call back Url in your Twitter app settings page. Every thing will work correctly after that. :)

How do the App knows whether the user did a Facebook POST or DISCARD

In my Android Game,I am using Facebook SDK to share the open graph story. When the user sees the sharin screen. The user may post it or it can be discarded by pressing the back button.
After the user returs to the game, I need to know whether the user has posted the story or discarded it. I need to reward the user if he shares it.
For now, I use the below code to know the status. The code reaches onSuccess() even for POST or DISCARD.
Code
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
//always gets called
socialShareType=FB_SHARE;
System.out.println("socialShareType in FB onSuccess : " + socialShareType);
Log.d("FBshare", "Share done Successfully");
}
#Override
public void onCancel() {
Log.d("FBshare", "Share cancelled");
}
#Override
public void onError(FacebookException error) {
// TODO Auto-generated method stub
Log.d("FBshare", "Share error");
}
});

Android Facebook LoginButton Callback jumps to canceled

I have the following code. It is a simple test of the callback function of the LoginButton in Facebook's Android API.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
callbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton)findViewById(R.id.login_button);
loginButton.setReadPermissions("user_friends");
loginButton.setReadPermissions("email");
loginButton.setReadPermissions("public_profile");
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Log.e("SUCCESS", "LOGIN SUCCESSFUL");
}
#Override
public void onCancel() {
Log.e("CANCEL", "Cancelled");
}
#Override
public void onError(FacebookException e) {
Log.e("ERROR", "Facebook Exception");
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
The only problem is that whenever I click the loginButton, a dialog appears and disappears for a brief moment, and then the logcat prints out the "CANCEL" text. I cannot seem to fix this error, and I'm not clicking cancel, because that dialog simply shows up and immediately disappears.
Please help me fix this?
As Facebook now requires review of applications which use publish access, you need to log into Facebook Developers Console, in Apps section select your app, click on Roles and add tester (or admin) role.
After this you should be able to get proper access token.
This answer helped me in similar situation.
https://stackoverflow.com/a/31625256/1987045
Call LoginManager.getInstance().logOut(); before attempting a sign in.
I encountered this issue.
It seems to be the case that if you attempt to login (using logInWithReadPermissions or logInWithPublishPermissions) when you already have an access token (with all of the required permissions) then the onCancel callback is executed.
That is to say you should not be logging the user in because the user is already logged in. Check for this first.
My solution:
I had the same problem. The callback was always received by onCancel() method.
I was performing a native login (meaning I was using Facebook App), so after talking with a work-mate, I unistalled my Facebook App to check whether a non-native loging was possible and run my app. To my surprise, before receiving the callback on the onCancel() method, a message informed me my Facebook App ID was wrong, so that was all. I had copied a wrong one instead of the one you get from https://developers.facebook.com/apps.
Now it works and even displays the permissions dialog. What I mean with this is that always try native and non-native. Maybe you get the answer from any of them.
For me this happened because I was calling finish() on my Activity before the Facebook callbacks could complete, causing the activity to finish with RESULT_CANCELED instead of RESULT_OK.
More specifically, my buggy code looked something like this:
#Override
protected void onStart() {
super.onStart();
if (!mAuthRequested) {
mAuthRequested = true;
promptSignIn();
} else {
finish();
}
}
What was happening is that once Facebook's auth activity finishes, onStart() gets called again, but else { finish(); } is invoked before any of Facebook's callbacks are. The fix was to remove the else block.
I hope this helps someone!

Android Facebook SDK authorize methods shows dialog every time

I'm writing an Android application that should upload photos to Facebook.
Everything works just fine except one thing. When I called the Facebook.authorize() method for the first time the Facebook dialog was shown with requested permissions and 'Allow'/'Don't Allow' buttons. That was OK. But when I run my app for the secong time I've got the same dialog, but with message that my application allowed already and suggestion to press OK button.
Is there a way to avoid this second dialog? Should I skip the authorize method in some conditions?
I tried to call the Facebook.isSessionValid() method before authorize method, but this did not help.
Here is my simplified code:
mFacebook = new Facebook(APPLICATION_ID);
mFacebookAsync = new AsyncFacebookRunner(mFacebook);
if (mFacebook.isSessionValid()) {
uploadPictureFile();
}
else {
mFacebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
Toast.makeText(PhotoFeederFacebookSendActivity.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
finishWithResultCode(RESULT_CANCELED);
}
#Override
public void onError(DialogError e) {
Toast.makeText(PhotoFeederFacebookSendActivity.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
finishWithResultCode(RESULT_CANCELED);
}
#Override
public void onComplete(Bundle values) {
uploadPictureFile();
}
#Override
public void onCancel() {Toast.makeText(PhotoFeederFacebookSendActivity.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show();
finishWithResultCode(RESULT_CANCELED);
}
});
}
And here is my onActivityResult method:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mFacebook.authorizeCallback(requestCode, resultCode, data);
}
Any help appreciated. Thanks.
You need to call mFacebook.setAccessToken("your token") before mFacebook.isSessionValid()
and you need to save the token to preference yourself
If you only intend to update status see my post here...
Android Facebook Graph API to update status

Categories

Resources