Versions Compared

Key

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

...

Step Summary

  1. Add the Initialization code for the SDK

  2. Register all the app UIViewControllers to the SDK

  3. Add the tagged Wrappers, and tagged Buttons using the accessabilityLabel

  4. Note the transition events

  5. Add the testing Single Data

  6. Test everything is working

  7. Change everything to production code

  8. Your app is now prepared for monetization with us.

...

Code Block
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
    }
}

...

Note

This appID is not the same as the Manifest App Id Info.plist GADApplicationIdentifieryou used in previous steps.

Tagged Wrappers

Tagged Wrappers are the container inside which the ads will show, they are normal UIView wrappers with the accessabilityLabel attribute set. You need to add as many as you can, remember that placing a tagged wrapper does not mean we need to use it.

...

Info

If the specified accessibilityLabel is detected found in the UIView, an ad will be placed inside it based on inserted into it according to the single tag configuration data.

...

This example demonstrates the automatic display of an interstitial ad during the transition from one screen to another (from InitialScreenViewController to NewsPostDetailScreenViewController).

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.

Code Block
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)
        ...
    }
    ...
}

...

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.

Code Block
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: "buttonplay_video_trailer_tag")
    }
    ...
}

According to the above configuration, the buttonplay_video_trailer_tag must be specified inside the InitialScreenViewController for the button via the accessibilityLabel parameter.

...

Code Block
languageswift
import UIKit
import R89SDK

class InitialScreenViewController: UIViewController {
    ...
    override func viewDidLoad() {
        super.viewDidLoad()
        isModalInPresentation = true
        R89SDK.shared.registerLifecycle(uiViewController: self)
        // Do any additional setup after loading the view.
    }
    
    // The button's press handler method
    @IBAction func showNewsDetailsplayVideoTrailer(_ sender: UIButton) {
        // This method will be called after the interstitial ad is closed.
        ...
    }
    ...
}

...

  • Remove the methods R89SDK.shared.setDebug().

  • Change the GADApplicationIdentifier in the info.plist for the production one.

  • Change the appId and publisherId in the initialization method for the production ones.Change the r89ConfigId in the formats for the production ones.

  • it’s also recommended to remove R89SDK.shared.setLogLevel(level: LogLevels.debug) but not needed.

...