Wiki

Clone wiki

AATKit iOS / Proposal / AATKit initialization2

Using the AddApptr SDK in your iOS project

  1. Getting Started
  2. AATKit Initialisation
  3. Consent Handling
  4. Formats
  5. Targeting
  6. Advanced

AATKit Initialisation

AATKit initialization

Configuring AATKit

Before loading ads, call the initializeWithConfiguration: method on AATKit, which initializes the SDK. This only needs to be done once, ideally at app launch. You should call initializeWithConfiguration: as early as possible.

initializeWithConfiguration: is called with AATConfiguration object which contains the necessary configuration needed to initialize AATKit

Example usage:

Objective-C:

AATConfiguration* configuration = [[AATConfiguration alloc] init];
configuration.delegate = self;
[AATKit initializeWithConfiguration:configuration];
Swift:
let configuration = AATConfiguration()
configuration.delegate = self
AATKit.initialize(with: configuration)

Note: Since AATKit 2.66.10 you are able to reconfigure AATKit. To do so, you can use the class method:

#!objective-c
+ (void)reconfigureUsingConfiguration:(nonnull AATRuntimeConfiguration*)configuration
        NS_SWIFT_NAME(reconfigure(using:));

configuration: Contains new runtime information. Only properties in AATRuntimeConfiguration are considered.

Using TestID for testing

You can use your TestID to test your application. The accountID can be set in your AATConfiguration object. The accountID will be sent to you after registering at www.AddApptr.com.

Objective-C:

 configuration.testModeAccountID   = <<your account ID>>;
Swift:
 configuration.testModeAccountID = <<your account ID>>
The AddApptr SDK identifies your app using the bundleID from the Apple app store. For the identification to work properly, it is important to disable the test-mode before going public with your app. Simply do not set the testModeAccountID property.

Remember to disable test mode before you submit to the app-store! Disabling is done by omitting the testID.

Activate the debug mode

To see debug output in the Xcode console, you can use the following method before initializing AATKit:

#!objective-c
+ (void)debug:(bool)flag; //default is set to NO

Example usage:

Objective-C:

#!objective-c
[AATKit debug:YES];
Swift:
#!swift
AATKit.debug(true)

Setting the view controller

You can set the view controller for your ad requests on the AATConfiguration object when initializing the AATKit: Objective-C:

#!objective-c
configuration.defaultViewController = <<your Current ViewController>>;
Swift:
#!swift
configuration.defaultViewController = <<your Current ViewController>>

You should set the view controller every time you change to another view controller, on which you want to display ads:

Objective-C:

[AATKit setViewController:self];
Swift:
AATKit.setViewController(self)

There are also special APIs for setting the view controller, e.g. for native ads. Please take a look at these chapters to learn more about that.

Important: For some ad networks, like the Google ad networks, you always have to set the view controller when performing an ad request, because they will ignore any ad request that doesn't hand over a view controller.

back (Home)

Updated