Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The first recommended place to initialize the SDK is the UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) method.

Code Block
breakoutModewide
languageswift
import UIKit
import R89SDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // This is for testing purposes, remove it on prod
        R89SDK.shared.setLogLevel(level: LogLevels.debug)
        // This is for testing purposes, remove it on prod
        R89SDK.shared.setDebug()
  
        addTestingSingleTagData()  /* This is a later step */
        
        R89SDK.shared.initialize(
            publisherId: "TestPublisherID", /* This is for testing purposes, change it on prod */
            appId: "TestAppId", /* This is for testing purposes, change it on prod */
            singleLine: true,
            publisherInitializationEvents: nil)
        return true
    }
}

...

Primarily the transition needs to be configured via the dashboard, but for testing purposes, it could be configured locally by using SingleTagConfigBuilder.shared instance in your code.

wide
Code Block
breakoutMode
import UIKit
import R89SDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        ...
        addTestingSingleTagData()  /* This is a later step */
        R89SDK.shared.initialize(...)
        return true
    }
    
    func addTestingSingleTagData(){
        // Add a Screen that is a UIViewController, the screenName you can get it by logging this in you code ->
        // in viewDidLoad you can use self.name ->
        // on InitialScreenViewController -> InitialScreenViewController
        // on NewsPostDetailScreenViewController -> NewsPostDetailScreenViewController
        
        let screenBuilder = SingleTagConfigBuilder.shared
            .addAdScreenBuilder(isFragment:false,screenName: "InitialScreenViewController")
        
        /* trigger interstitial when we transition from "InitialScreenViewController" (ScreenBuilder.screenName) TO NewsPostDetailScreenViewController */
        screenBuilder.addInterstitial(eventsToTrackTo: "NewsPostDetailScreenViewController",
                                      eventsToTrackButton: nil)
        ...
    }
    ...
}

Hence, the interstitial ad will be displayed whenever InitialScreenViewController presents InfiniteScrollViewController.

wide
Code Block
breakoutMode
languageswift
import UIKit
import R89SDK

class InitialScreenViewController: UIViewController {
    ...
    override func viewDidLoad() {
        super.viewDidLoad()
        ..
        R89SDK.shared.registerLifecycle(uiViewController: self)
        // Do any additional setup after loading the view.
    }
    
    @IBAction func presentNewsPostDetailScreen(_ sender: UIButton) {
        // On this transition event, the interstitial ad will be displayed.
        present(NewsPostDetailScreenViewController(), animated: true)
    }
    ...
}

...

Primarily the button-press needs to be configured via the dashboard, but for testing purposes, it could be configured locally by using SingleTagConfigBuilder.shared instance in your code.

wide
Code Block
breakoutMode
languageswift
import UIKit
import R89SDK
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        ...
        addTestingSingleTagData()  /* This is a later step */
        R89SDK.shared.initialize(...)
        return true
    }
    
    func addTestingSingleTagData(){
        let screenBuilder = SingleTagConfigBuilder.shared
            .addAdScreenBuilder(isFragment:false,screenName: "InitialScreenViewController")
        ...
        /* trigger an interstitial when a button with this tag is pressed in "InitialScreenViewControllerj" (ScreenBuilder.screenName) */
        screenBuilder.addInterstitial(eventsToTrackTo: nil,
                                      eventsToTrackButton: "play_video_trailer_tag")
    }
    ...
}

...