UIKit and Objective-C
Add Fload's attribution SDK to a UIKit app, in Swift or Objective-C. It takes one package and two lines in your app delegate.
What you need
- iOS 15 or later as your deployment target.
- Your app's write key.
- RevenueCat in your app, if you want revenue per keyword. The SDK doesn't depend on it.
1. Add the package
In Xcode, choose File → Add Package Dependencies. Enter this URL:
https://github.com/fload-ai/fload-attribution-ios.gitChoose Up to Next Major Version from 1.0.0, and add the FloadAttribution product to your app target. The package has no other dependencies.
2. Start it in your app delegate (Swift)
Call Fload.configure(key:) once, in application(_:didFinishLaunchingWithOptions:). It returns at once and does its work in the background.
import UIKit
import FloadAttribution
import RevenueCat
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Purchases.configure(withAPIKey: "appl_…")
Fload.configure(key: "fload_pk_…")
Fload.setUserId(Purchases.shared.appUserID)
return true
}
}When a user logs in, RevenueCat's id changes. Send the new one too:
Purchases.shared.logIn("user_123") { customerInfo, created, error in
Fload.setUserId(Purchases.shared.appUserID)
}Fload keeps every id an install has had, so purchases before and after login both count.
3. Objective-C apps
From version 1.0.2, the SDK has an Objective-C interface. The module is FloadAttribution and the class is FLDAttribution. Add the package as in step 1, with 1.0.2 or later, then call it from your app delegate:
@import FloadAttribution;
@import RevenueCat;
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[RCPurchases configureWithAPIKey:@"appl_…"];
[FLDAttribution configureWithKey:@"fload_pk_…"];
[FLDAttribution setUserId:RCPurchases.sharedPurchases.appUserID];
return YES;
}After a login, call [FLDAttribution setUserId:…] again with RevenueCat's new app user id. FLDAttribution.installReference gives this install's random reference, for support questions. It's nil before configureWithKey:.
4. Check it works
Turn on debug logs while you test:
Fload.configure(key: "fload_pk_…", options: FloadOptions(logLevel: .debug))In Objective-C (version 1.0.2 or later):
[FLDAttribution configureWithKey:@"fload_pk_…" endpoint:nil logLevel:FLDLogLevelDebug];Leave endpoint as nil. The levels are FLDLogLevelNone, FLDLogLevelError, FLDLogLevelWarning (the default), FLDLogLevelInfo and FLDLogLevelDebug.
Run the app on a real device and look for the subsystem com.fload.attribution in Xcode's console.
- The Simulator has no AdServices token, so installs from it arrive without attribution.
- Apple sends test data to builds in developer mode. Fload leaves those installs out of your numbers.
Remove the debug option before you ship.
5. Ship it
Ship the update. Installs start to arrive as people open the new version. Fill in your App Store privacy answers from Privacy.
Source code and changelog: github.com/fload-ai/fload-attribution-ios.