Content SharingPersonalized ExperiencesTechnical

Introducing: An App Invite Feature With Just a Few Lines Of Code

By April 23, 2015 No Comments

Invites are a huge part of spreading mobile apps. The best time to get your users to tell their friends about your app is while they enjoy using it, and while word of mouth advertising is a good channel, what works even better is to build ways your users can invite their friends straight from your app.

Unfortunately, up until now, every app had to reinvent the wheel, reimplementing the same invite feature over and over — getting the right permissions, pulling from device contacts, and rebuilding the same UI. This is especially painful on iOS because the APIs are all using the older CoreFoundation framework, requiring manually memory management and bridging.

Branch makes app invites incredibly easy

Branch is changing this by making building app invites incredibly simple. We are providing a ready to go, simple to use and easy to extend framework for sending invitations and welcoming invited users . SMS and Email invitations are provided out of the box, and additional contact providers are on their way. Now you can focus more on your app — Branch will take care of the whole invitation process for you. Check out how easy it is !

Example Feature Flow

Example Feature Flow

If you are already using Branch (if you are not, you can sign up here ), adding these items to your project is super easy.

your project is super easy.

The welcome screen can be as simple as a few extra lines in your Branch initialization callback:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[Branch getInstance] initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
        if ([BranchWelcomeViewController shouldShowWelcome:params]) {
            BranchWelcomeViewController *welcomeController = [BranchWelcomeViewController branchWelcomeViewControllerWithDelegate:self branchOpts:params];

            [self.window.rootViewController presentViewController:welcomeController animated:YES completion:NULL];
        }
    }];

    return YES;
}

#pragma mark - BranchWelcomeControllerDelegate required methods
- (void)welcomeControllerConfirmedInvite {
    [self.presentingController dismissViewControllerAnimated:YES completion:^{
        NSLog(@"Great -- glad you get to join your friend");
    }];
}

- (void)welcomeControllerWasCanceled {
    [self.presentingController dismissViewControllerAnimated:YES completion:^{
        NSLog(@"Sorry about that, guess we had the wrong person");
    }];
}

The Invite screen requires a few additional items to set up the inviting user information, but is still pretty easy to add to any old View Controller in your app.

- (IBAction)inviteButtonPressed:(id)sender {
    id branchInviteViewController = [BranchInviteViewController branchInviteViewControllerWithDelegate:self];

    [self presentViewController:branchInviteViewController animated:YES completion:NULL];
}

#pragma mark - BranchInviteControllerDelegate required methods
- (void)inviteControllerDidFinish {
    [self dismissViewControllerAnimated:YES completion:^{
        [[[UIAlertView alloc] initWithTitle:@"Hooray!" message:@"Your invites have been sent!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    }];
}

- (void)inviteControllerDidCancel {
    [self dismissViewControllerAnimated:YES completion:^{
        [[[UIAlertView alloc] initWithTitle:@"Awe :(" message:@"Your invites were canceled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    }];
}

- (NSString *)invitingUserFullname {
    return @"Graham Mueller";
}

And here’s the best part — if the UI isn’t quite to your taste (whether it just doesn’t quite match your theme, or you want to redo it entirely), both the Invite and Welcome screen offer a huge amount of customization points, allowing you all the control you need to make it work in your app without having to rewrite all the underlying contact finding code.

This should provide a great opportunity for you to add invites to your app with minimal friction. Check out the code on GitHub and get it into your project today!

Branch is a mobile linking platform providing unified mobile experiences and measurement for more than 27,000 mobile apps, including Airbnb, Slack, Reddit, Tinder and Amazon. Branch’s free linking platform can help you grow your mobile app through features like deep linking, sharing, referrals, mobile banners and interstitials, custom app onboarding, and unified attribution across platforms and channels. Learn more about Branch.