The Braintree iOS SDK helps you accept payments in your iOS app.



There are two ways to include Braintree in your project.

Via CocoaPods

Add the library to your Podfile:

pod 'Braintree', '~> 3.9'

Then run pod install.

Not familiar with CocoaPods? Learn how CocoaPods works.


While we recommend CocoaPods as our officially supported integration technique, it is possible to pull in Braintree code manually. See the Braintree iOS Manual Integration Instructions.

Setup for app switch

To handle payments that involve switching to another app or SFSafariViewController for authentication, you must register a URL type and configure your app to return from app switches.

Register a URL type

  1. In Xcode, click on your project in the Project Navigator and navigate to App Target > Info > URL Types
  2. Click [+] to add a new URL type
  3. Under URL Schemes, enter your app switch return URL scheme. This scheme must start with your app's Bundle ID and be dedicated to Braintree app switch returns. For example, if the app bundle ID is com.your-company.Your-App, then your URL scheme could be com.your-company.Your-App.payments.

If you have multiple app targets, be sure to add the return URL type for all of the targets.

Testing the URL type

You can test out your new URL scheme by opening up a URL that starts with it (e.g. com.your-company.Your-App.payments://test) in Mobile Safari on your iOS Device or Simulator.

In addition, always test your app switching on a real device.

Update your application delegate

In your AppDelegate's application:didFinishLaunchingWithOptions: implementation, use setReturnURLScheme: with the value you set above.

For example:

#import "AppDelegate.h"
#import <Braintree/Braintree.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Braintree setReturnURLScheme:@"com.your-company.Your-App.payments"];
    return YES;

Then in your application delegate, pass the payment authorization URL to Braintree for finalization:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    if ([url.scheme localizedCaseInsensitiveCompare:@"com.your-company.Your-App.payments"] == NSOrderedSame) {
        return [Braintree handleOpenURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
    return NO;

// If you support iOS 8, add the following method.
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    if ([url.scheme localizedCaseInsensitiveCompare:@"com.your-company.Your-App.payments"] == NSOrderedSame) {
        return [Braintree handleOpenURL:url sourceApplication:sourceApplication];
    return NO;

Supporting iOS 9

iOS 9 introduces new security restrictions that can impact the behavior of the Braintree SDK.

App Transport Security

As of 09/30/2015, all endpoints contacted by the Braintree iOS SDK are compatible with Apple's App Transport Security requirements. No ATS exceptions are necessary.

If your app's Info.plist previously contained NSExceptionDomains entries for or (for apps using Kount), we recommend you remove these exceptions. As with any changes which may affect your app in production, please be sure to test and verify all behavior before releasing an update to the App Store.


As of version 3.9.4, the Braintree iOS SDK works with apps that have bitcode enabled.

See also