The iOS SDK is a standard mergeable dynamic library, compatible with iOS 13.0 and higher. Xcode 15.3+ is required, but Batch will work with all Swift versions, along with Objective-C.
It supports the following architectures:
x86_64
arm64 (both for iOS, and iOS Simulator on Apple Silicon)
arm64e.
Catalyst is supported.
The iOS SDK also supports visionOS in a restricted usage since:
In-App messaging and mobile landings are unavailable.
In-App rating is not supported on visionOS due to an OS limitation.
First, simply add this line to your Podfile to integrate Batch in your project:
Podfile
pod 'Batch', '~> 2.0'
Then, run pod install in your Podfile folder, and open the .xcworkspace that was created. You're ready to go! In order to update Batch SDK, simply run pod update in that directory.
If you don't have a Podfile or are unsure on how to proceed, see the CocoaPods usage guide.
Note: Due to CocoaPods limitations, the Batch Pod is not a mergable library and has no code signing. If you need one of those, please use SPM or manually integrate the XCFramework.
Batch is only available on Carthage 0.30 and higher
Simply add this line to your Cartfile to integrate Batch in your project:
github"BatchLabs/Batch-iOS-SDK"
Do not add Batch to the "carthage copy-frameworks" script input/output.
XCFramework distribution is supported since Batch 1.18.0 and Carthage 0.38.
Apple now requires Privacy Manifest that's not available with Carthage.
Your first start
Implement the Batch startWithAPIKey: method in your AppDelegate application:didFinishLaunchingWithOptions: method:
If you're making a SwiftUI app, you will need to add a delegate first.
import SwiftUI
import Batch
class MyAppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BatchSDK.start(withAPIKey: "YOUR_API_KEY")
return true
}
}
@main
struct BatchApp: App {
// Set an explicit delegate to integrate Batch in
@UIApplicationDelegateAdaptor(MyAppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
YOUR_API_KEY is your SDK API Key. You'll find it in ⚙ Settings → General.
This API key must not be mistaken for the APNS environment Batch will output to the Xcode logs when starting. The environment depends on the app's provision, not on the Batch API Key used.
Testing your integration
Congratulations on finishing the bulk of the integration!
If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in the Xcode console.
Batch also provides a simple debug tool that allows you to test your integration (⚙ Settings → Debug) and a profile view that shows all the data available for a specific user ID.