RudderStack is a customer data pipeline tool for collecting, routing and processing data from your websites, apps, cloud tools, and data warehouse.
More information on RudderStack can be found here.
-
Add Appsflyer as a destination in the Dashboard and provide
devKeyandappleAppIdfrom your iTunes profile. -
Rudder-Appsflyer is available through CocoaPods and Swift Package Manager (SPM).
pod 'Rudder-Appsflyer'You can also add the RudderStack iOS SDK via Swift Package Mangaer, via one of the following two ways:
- Go to File - Add Package, as shown:
-
Enter the package repository (
git@github.com/rudderlabs/rudder-integration-appsflyer-ios.git) in the search bar. -
In Dependency Rule, select Up to Next Major Version and enter
4.0.0as the value, as shown:
-
Select the project to which you want to add the package.
-
Finally, click on Add Package.
To leverage package.swift, use the following snippet in your project:
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Rudder-Appsflyer",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "Rudder-Appsflyer",
targets: ["Rudder-Appsflyer"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "git@github.com/rudderlabs/rudder-integration-appsflyer-ios.git", from: "4.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Rudder-Appsflyer",
dependencies: [
.product(name: "Rudder-Appsflyer", package: "rudder-integration-appsflyer-ios")
]),
.testTarget(
name: "RudderStackTests",
dependencies: ["Rudder-Appsflyer"]),
]
)- Initialize the
AppsflyerSDK before initializing the Rudder SDK as shown below:
#import <AppsFlyerLib/AppsFlyerLib.h>
[[AppsFlyerLib shared] initWithDevKey:<devKey> appleAppId:<appleAppId>];
[AppsFlyerLib shared].isDebug = YES;
// AppsFlyer SDK v7 never starts automatically. Call start from inside the
// session-ready listener, after any pre-conditions (ATT/consent) resolve.
[[AppsFlyerLib shared] registerSessionReadyListener:^{
[[AppsFlyerLib shared] start];
}];
Note: If
initWithDevKey:appleAppId:andstartare not called, this integration still forwards events to the AppsFlyer SDK, but the SDK will not send them to AppsFlyer — with no error reported.
Version 4.0.0 of this integration requires AppsFlyer SDK 7.x. If you are upgrading from 3.x:
- Replace
setAppsFlyerDevKey:andsetAppleAppID:withinitWithDevKey:appleAppId:— the old setters are read-only properties in AppsFlyer 7. - Move your
startcall fromapplicationDidBecomeActive:into aregisterSessionReadyListener:block — the SDK no longer starts automatically, and starting it from the listener preserves the first session even when you deferstartfor consent or ATT. waitForATTUserAuthorizationWithTimeoutInterval:is deprecated — collect ATT consent inside the session-ready listener instead.- The email set via the
identifyevent is now hashed on-device (SHA-256) by AppsFlyer'ssetUserEmailAPI; no change is needed in youridentifycalls. - To stay on AppsFlyer 6.x, keep using the 3.x releases of this integration.
Put this code in your AppDelegate.m file under the method didFinishLaunchingWithOptions
RSConfigBuilder *builder = [[RSConfigBuilder alloc] init];
[builder withDataPlaneUrl:DATA_PLANE_URL];
[builder withFactory:[RudderAppsflyerFactory instance]];
[RSClient getInstance:WRITE_KEY config:[builder build]];
Follow the steps from the RudderStack iOS SDK.
If you come across any issues while configuring or using this integration, please feel free to start a conversation on our Slack channel. We will be happy to help you.

