What does YesGraph do for you?

YesGraph boosts the performance of invite flows & referral programs by recommending exactly who each user 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 improve our rankings iteratively by learning about your users, who they invite, and who accepts invites. With YesGraph, you get a customizable UI, contact filtering options, and a huge blacklist of no-reply emails and phones.

Integrating the YesGraph SDK

You may integrate the YesGraph IOS SDK as a CocoaPods library, as a Carthage library, as a framework, 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.

When you have successfully received your client key, you must configure the YesGraph SDK with newly received client key and user ID that goes with it.

User ID and User Info

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.


let source = YSGSource()
source.name = "Name"
source.email = "Email"
source.phone = "+1 123 123 123"

YesGraph.shared().contactOwnerMetadata = source
[[YesGraph shared] configureWithUserId:@"<USER_ID>"];

YSGSource* source = [[YSGSource alloc] init];
source.name = @"Name";
source.email = @"Email";
source.phone = @"+1 123 123 123";
[[YesGraph shared] setContactOwnerMetadata:source];

Client Key

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

YesGraph.shared().configureWithClientKey(jsonResult["message"] as! String)
[[YesGraph shared] configureWithClientKey:clientKey];

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.

let urlPath: String = "<YOUR SERVER URL>" + YesGraph.shared().userId!
// e.g. "https://yesgraph-client-key-test.herokuapp.com/client-key/"

let url: NSURL = NSURL(string: urlPath)!
let request: NSURLRequest = NSURLRequest(URL: url)
let session: NSURLSession = NSURLSession.sharedSession()
let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
    let jsonResult: NSDictionary = try! (NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary)!
    YesGraph.shared().configureWithClientKey(jsonResult["message"] as! String)
NSString *urlPath = [NSString stringWithFormat:@"<YOUR SERVER URL>/%@", [YesGraph shared].userId];
// e.g. "https://yesgraph-client-key-test.herokuapp.com/client-key/"

NSURL *url = [NSURL URLWithString: urlPath];
NSURLSession *session = [NSURLSession sharedSession];

[[session dataTaskWithURL:url
        completionHandler:^(NSData *data,
                            NSURLResponse *response,
                            NSError *error) {
            NSError *jsonError;
            NSDictionary *jsonResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
            NSString *clientKey = [jsonResult objectForKey:@"message"];
            [[YesGraph shared] configureWithClientKey:clientKey];
        }] resume];

How to use the YesGraph SDK

Once YesGraph SDK is correctly configured and used, the SDK provides a simple convenience API for you to be able to use it very quickly. This API is represented by a single class YesGraph, which is a singleton instance retrieved with method shared. There are multiple properties available for you to customize, such as the number of suggested invites that will be displayed when using contact book to invite or the text that is displayed on the share sheet screen.

YesGraph.shared().numberOfSuggestions = 5
YesGraph.shared().shareSheetText = "Demo our SDK by sharing YesGraph with your contacts"
[YesGraph shared].numberOfSuggestions = 5;
[YesGraph shared].shareSheetText = @"Demo our SDK by sharing YesGraph with your contacts";

Once the properties are set, you can instantiate YSGShareSheetController, which is a simple UIViewController that represents a simple, modern share sheet.

let shareController = YesGraph.shared().shareSheetControllerForAllServicesWithDelegate(self)
YSGShareSheetController *shareController = [[YesGraph shared] shareSheetControllerForAllServicesWithDelegate:self];

Share sheet can use multiple sharing services (Contact book, Facebook and Twitter are currently supported), but calling method shareSheetControllerForAllServicesWithDelegate: will display all supported that are also configured on user’s device.

When you have an instance of YSGShareSheetController, all you have to do is display it in any way that you like:

let navController = UINavigationController.init(rootViewController: shareController)
self.presentViewController(navController, animated: true, completion: nil)
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:shareController];
[self presentViewController:navController animated:YES completion:nil];

Because sometimes you want to provide different messages for specific share services and know when sharing is finished, you can implement YSGShareSheetDelegate.

func shareSheetController(shareSheetController: YSGShareSheetController, messageForService service: YSGShareService, userInfo: [String : AnyObject]?) -> [String : AnyObject] {
    if let _ = service as? YSGInviteService {
        if let _ = userInfo?[YSGInviteEmailContactsKey] {
            return [YSGShareSheetSubjectKey : "We should check out YesGraph", YSGShareSheetMessageKey : "Check out YesGraph, they help apps grow: www.yesgraph.com/#iosce"]
        else {
            return [YSGShareSheetMessageKey : "Check out YesGraph, they help apps grow: www.yesgraph.com/#iosce"]
    return [YSGShareSheetMessageKey : "Check out YesGraph, they help apps grow: www.yesgraph.com/#iosce"]
- (NSDictionary *)shareSheetController:(YSGShareSheetController *)shareSheetController messageForService:(YSGShareService *)service userInfo:(NSDictionary *)userInfo
    if ([service isKindOfClass:[YSGInviteService class]])
        if ([userInfo valueForKey:YSGInviteEmailContactsKey])
            return @{ YSGShareSheetSubjectKey : @"We should check out YesGraph", YSGShareSheetMessageKey : @"Check out YesGraph, they help apps grow: www.yesgraph.com/#iosce" };
        else {
            return @{ YSGShareSheetMessageKey : @"Check out YesGraph, they help apps grow: www.yesgraph.com/#ioscs" };
    return @{ YSGShareSheetMessageKey : @"Check out YesGraph, they help apps grow: www.yesgraph.com/#iosce" };

When user has completed the sharing, the SDK calls the shareSheetControllerDidFinish: method on delegate. See our example apps for an easy example of how to get started with the YesGraph SDK.