Skip to main content

1. Launch SDK

Initialize the SDK:
import Qonversion

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let config = Qonversion.Configuration(projectKey: "[projectKey]", launchMode: .analytics)
    Qonversion.initWithConfig(config)
  	return true
}
#import "Qonversion.h"
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    QONConfiguration *configuration = [[QONConfiguration alloc] initWithProjectKey:@"[projectKey]" launchMode:QONLaunchModeAnalytics];
    [Qonversion initWithConfig:configuration];
    
    return YES;
}

2. (Optional) Set User ID

If you want to implement cross-platform (Android, IOS, and Web) user entitlement management, please, follow the User Identity guide. To match Qonversion revenue events to users in third-party tools, you need to set the identical user IDs in all of them:
Qonversion.shared().setProperty(.userID, value: "yourSideUserId")
[[Qonversion sharedInstance] setProperty:QNPropertyUserID value:@"yourSideUserId"];
The user ID improves the quality of events matching to the platforms where event attribution is not exclusively based on IDFA.

3. (Optional) Set IDFA (Identifier for Advertisers, iOS 14.5+ only)

On iOS 14.5+, after requesting the app tracking permission using ATT, you need to notify Qonversion if tracking is allowed and IDFA is available. This will help to have precise attribution in Adjust, AppsFlyer, Singular and other Qonversion integrations.
ATTrackingManager.requestTrackingAuthorization { status in
    switch status {
    case .authorized:
        Qonversion.shared().collectAdvertisingId()
      
    // handle other states below
    }
}
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
    switch (status) {
        case ATTrackingManagerAuthorizationStatusAuthorized:
            [[Qonversion sharedInstance] collectAdvertisingId];
            break;
        
        // handle other states if needed
        
        default:
          break;
    }
}];