Client SDK

Setupanchor

important

The SSL certificates for all Braintree SDKs are set to expire by June 30, 2025. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the iOS SDK to version 6.17.0+ for the new SSL certifications.

If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.

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

Requirementsanchor

  • Xcode 15.0+
  • A minimum deployment target of iOS 14.0
  • Swift 5.9+ (or Objective-C)

It goes without saying, but we’ll say it anyway: we always recommend using the latest versions of our SDKs. In order to communicate securely with the Braintree gateway, you must use at least version 4.10.0 of the iOS SDK.

note

Our iOS SDK and its frameworks follow semantic versioning. When updating your integration, be sure to update each framework to the latest version.

Installationanchor

There are multiple ways to include Braintree in your project. See the Installation section of our README.

Setup for app context switchinganchor

In order to use the Venmo flow, your application must be set up for Universal Links. You will need to use a custom path dedicated to Braintree app switch returns. This URL must also be added to your app association file with wildcards allowed to ensure we receive the expected data on return.

An example apple-app-site-association may look like the following:

  1. JSON
{
  "applinks": {
    "details": [
      {
        "appID": "com.your-app-id",
        "paths": [
          "/braintree-payments/*"
        ]
      }
    ]
  }
}

Handle app context switchinganchor

Then pass the payment authorization URL to Braintree for finalization.

If you’re using SwiftUI, you must add the onOpenURL(perform:) modifier to your ContentView, and then call BTAppContextSwitcher's handleOpen(url:) method.

  1. Swift
.onOpenURL { url in
    BTAppContextSwitcher.sharedInstance.handleOpen(url)
}

If you're using UISceneDelegate (introduced in iOS 13), call handleOpenURLContext method from within the scene:openURLContexts scene delegate method.

  1. Swift
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    URLContexts.forEach { context in
        if context.url.scheme?.localizedCaseInsensitiveCompare("com.your-company.your-app.payments") == .orderedSame {
            BTAppContextSwitcher.sharedInstance.handleOpenURL(context: context)
        }
    }
}

Otherwise, if you aren't using UISceneDelegate, call handleOpenURL method from within the application:openURL:options app delegate method.

  1. Swift
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    if url.scheme?.localizedCaseInsensitiveCompare("com.your-company.your-app.payments") == .orderedSame {
        return BTAppContextSwitcher.sharedInstance.handleOpen(url)
    }
    return false
}

Location Permissionsanchor

The Braintree iOS SDK uses device and browser location data for fraud detection when available (i.e. when location permissions have already been requested by your app and granted by the user). While you do not need to request location data from users in order to use Braintree, Apple requires a NSLocationWhenInUseUsageDescription key in your Info.plist if your app contains code referencing location APIs. If your app does not request location data, you will still need to include a NSLocationWhenInUseUsageDescription plist entry.

See also