What can YesGraph do for me?

YesGraph boosts the performance of sharing and invite flows by recommending exactly who users should invite. We use machine learning and social graph analysis to tailor results just for your product and users.

How does YesGraph work?

When you send us a user’s contacts, we return a ranked list in real-time. We tune our ranking by learning about your past users, who they invited, and who joined. With YesGraph, you can have a customizable UI, filtering options, a huge blacklist of no-reply emails and landlines, and data enrichment.

Integrating the YesGraph SDK

You may integrate the YesGraph Android SDK as a Gradle library, as a static library, or manually.

Since the mobile app is considered an untrustworthy client, you will need to authenticate with a secure backend server that must be under your control. More information is available in Authentication.

Once you have setup the client-key endpoint on your secure backend server, configure the YesGraph SDK with the client-key and userId. The SDK provides a simple convenience API represented by a single class called YesGraph.

User ID and Source

First, set your user’s unique User ID and name, email, and phone for the user in YSGSource. This tells YesGraph information about your user, and can help us with our rankings.

This USER_ID should be the unique user identifier used for that user in your application. Source information – including name, phone number, and email, will help us identify the user corresponding to the USER_ID.

private YesGraph yesGraphApplication;

yesGraphApplication = (YesGraph) getApplicationContext();
yesGraphApplication.configureWithUserId("<USER_ID>");

yesGraphApplication.setSource("Some Name", "+1 123 456 7890", "someone@gmail.com");

Client Key

Retrieve the client key from your server using the following, and then call configureWithClientKey to set the client key.

yesGraphApplication.configureWithClientKey("<CLIENT_KEY>");

Here is a full example of the call to your server to retrieve the client key, and then setting the client key in the SDK.

String apiUrl = "<YOUR API URL>";
// e.g. "http://yesgraph-client-key-test.herokuapp.com/";
MyClientKey myClientKey = new MyClientKey();
myClientKey.fetchClientKeyForUserId(apiUrl, userId, new Handler.Callback() {
    @Override
    public boolean handleMessage(Message msg) {

        JSONObject jsonObject = (JSONObject) msg.obj;
        try {
            String clientKey = jsonObject.getString("message");

            // Get the client key and set it here. This is saved and used in further API calls.
            yesGraphApplication.configureWithClientKey(clientKey);
            return true;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return false;
    }

});

Using the YesGraph SDK

The YesGraph CustomTheme class manages look and feel. It has multiple properties available for you to customize, such as the number of suggested invites to display or the text on the share sheet screen.

CustomTheme customTheme=new CustomTheme();
customTheme.setNumberOfSuggestedContacts(5);

yesGraphApplication.setCustomTheme(customTheme);

See here for more properties that can be set on the Theme, including the setCONTACTS_FILTER_TYPE(int CONTACTS_FILTER_TYPE). Setting CONTACTS_FILTER_TYPE == 1 will display only users with phone numbers.

Once the properties are set, you can call ShareSheetActivity, which is a simple Activity that represents a simple, modern share sheet.

Intent intent = new Intent(context, com.yesgraph.android.activity.ShareSheetActivity.class);
startActivityForResult(intent,REQUEST_CODE_SHARE_SHEET);

Here’s our example share sheet. To further customize the look and feel – check out our styling guide.

The share sheet can use multiple sharing services (Contacts, Facebook, and Twitter are currently supported). But you can implement your own as a subclass of BasicShareService

public class MyShareService extends BasicShareService {
    public MyShareService(final Context context)
    {
        super.setContext(context);
        super.setIcon(context.getResources().getDrawable(com.yesgraph.android.R.drawable.icon));
        super.setColor(Color.parseColor("#444444"));
        super.setTitle("Yesgraph");
        super.setRunnable(new Runnable() {
            @Override
            public void run() {
                try {
                    Intent intent = new Intent(context, MyActivity.class);
                    context.startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

And then you can add this to share services with the code below.

ArrayList<Object> shareservices = yesGraphApplication.getShareServices();
MyShareService myShareService = new MyShareService(this);
shareservices.add(myShareService);

You can also remove some services that are set by default, by checking the instance (ContactShareService, FacebookShareService, TwitterShareService) and removing it from the array list. See an example here.

To customize the sharing messages, set these properties on the CustomTheme instance:

customTheme.setCopyLinkText("www.yesgraph.com/#android");
        
customTheme.setEmailSubject("We should check out YesGraph");
customTheme.setEmailText("Check out YesGraph, they help apps grow: www.yesgraph.com/#android");

customTheme.setSmsText("Check out YesGraph, they help apps grow: www.yesgraph.com/#android");