Initialize the SDK

After you add the AwesomeAds SDK to your project, you need to initialize it.

Initialize the SDK in the AppDelegate class of your iOS app, as shown here:

import UIKit
import SuperAwesome

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func applicationDidFinishLaunching(_ application: UIApplication) {
        AwesomeAds.initSDK(false)
    }
}
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [AwesomeAds initSDK:false];
    return YES;
}

@end

where the initSDK method takes a Boolean parameter indicating whether logging is enabled or not. For production environments, logging should be off.

Alternatively, you can call initSDK with a Configuration object and an optional callback that notifies you when the initialization is complete, as shown here:

import UIKit
import SuperAwesome

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func applicationDidFinishLaunching(_ application: UIApplication) {
        AwesomeAds.initSDK(
          configuration: Configuration(
              environment: .production,
              logging: true,
              options:["queryParam": "value"]
          )
        ) {
            // Run code after AwesomeAds is initialised
            print("AwesomeAds SDK init complete")
        }
    }
}
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    Configuration *config = [[Configuration alloc] initWithEnvironment:SAEnvironmentProduction logging:true options:@{@"queryParam": @"value"}];
    [AwesomeAds initSDKWithConfiguration:config completion:^{
        // Run code after AwesomeAds is initialised
    }];
    return YES;
}

@end

The Configuration object has 3 properties:

  • environment: Environment

    environment can be set to production or staging.

  • logging: Bool

    logging can be enabled or disabled. It should be disabled in production environments.

  • options: [String: String]?

    options is an optional dictionary that you can use to set additional tracking information in the form of key-value pairs. This information is sent when events are fired from the SDK.