Search code examples
javaandroidfacebooktwittersocial-networking

Reward user after successful sharing on social media on Android?


I'd like to know how to reward a user in my app after it has been successfully shared (from inside my app using a button) on any social media (Facebook, Twitter, Google+ etc.) Is there something like this in Twitter SDK for example?

In other words, how would I know that my app has been successfully shared?

I've read this answer but it doesn't help.


Solution

    1. For Twitter you can user Twitter Kit Native Composer to share a tweet which is basically an activity that you start with

      startActivity(intent);
      

      Later a broadcast will be fired by twitter with the result of the sharing, showing wether it was successful or not. More info here: https://dev.twitter.com/twitterkit/android/compose-tweets

    2. For Facebook you can get share status too, when you show sharing dialog you are able to provide a callback that will notify you about the success of sharing.

      public class MainActivity extends FragmentActivity {
          CallbackManager callbackManager;
          ShareDialog shareDialog;
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              callbackManager = CallbackManager.Factory.create();
              shareDialog = new ShareDialog(this);
              shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { 
                  // Here you'll get sharing status 
              });
      }
      

      More info: https://developers.facebook.com/docs/sharing/android?locale=en_US, check the Share Dialog paragraph.

    3. For LinkedIn you can get a result from their sdk similar to handling a network request.

    4. For Google+ you should check the result of started activity, regarding to this docs developers.google.com/+/mobile/android/share you should call startActivityForResult and then you most likely will get the result as activity result, Activity.RESULT_OK or Activity_RESULT_CANCELED. More info here: https://developer.android.com/training/basics/intents/result.html

    5. For Reddit you can use their REST api. I've found that you can compose a post for example: https://reddit.com/dev/api/#POST_api_compose that will response with success or failure.

    6. Fow WhatsApp, Hangouts, Telegram, Viber, Line and other messengers you are supposed to use native android way to share that unfortunately does not tell you the result.