Versions Compared

Key

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

...

Adding testing single tag data

Go back to the UIViewController AppDelegate class where we initialized the code, we are going to test all the transitions, tagged wrappers, and tagged buttons you have placed in the app.

Before the initialization method, we called addTestingSingleTagData() that which uses the SingleTagConfigBuilder to create the testing data needed for debugging the sdkSDK.

More info in → https://refinery89.atlassian.net/wiki/x/EgBWTw

Note

When using the SingleTagConfigBuilder you are not going to be able to select the ad units that are for production, they are by default the testing config id in https://refinery89.atlassian.net/wiki/x/EABGTw.

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()
        R89SDK.shared.initialize(...)
        return true
    }
    ...
    func addTestingSingleTagData(){
    
        // Add a Screen that is a UIViewController, the screenName you can get it by logging this in your code ->
        // in viewDidLoad you can use self.name ->
        // on InitialScreenViewController -> InitialScreenViewController
        // on NewsPostDetailScreenViewController -> NewsPostDetailScreenViewController
        
        let screenBuilder = SingleTagConfigBuilder.shared.addAdScreenBuilder(
            isFragment:false,
            screenName: "InitialScreenViewController")
        
        // Add a banner format to the wrapper with the tag bottom_ad_banner_container
        screenBuilder.addBanner(wrapperTag: "bottom_ad_banner_tagcontainer",
                                getAllWithTag: true,false, /* Only the first tagged wrapper in "InitialScreenViewController" with this tag will be used for this banner*/
                                wrapperRelativePositionInside: true, /* the ad will be placed inside of the wrapper */
                                wrapperRelativePositionAfter: false)
        
        /* trigger interstitial when we transition from "InitialScreenViewController" (ScreenBuilder.screenName) TO NewsPostDetailScreenViewController */
        screenBuilder.addInterstitial(eventsToTrackTo: nil, eventsToTrackButton: "button_tag")"NewsPostDetailScreenViewController",
                                      eventsToTrackButton: nil)
        
        /* trigger an interstitial when a button with this tag is pressed in "InitialScreenViewController" (ScreenBuilder.screenName) */
        screenBuilder.addInterstitial(eventsToTrackTo: "SecondSCreenViewController", eventsToTrackButton: nil)nil,
                                      eventsToTrackButton: "play_video_trailer_tag")
    }
    ...
}
Note

This step is for testing purposes and you are only going to see test ads when using this approach, but this is very helpful to us if you provide this peace of code to tell us where you want to place the ads.

Later when in production, this code have been removed and you have hopefully added flexible tagged wrappers and tagged all the button as possible so we can change your ad slots from the server without the need of updating the app.

Go into production

...

into production

...

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

  • Change the App id 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.DEBUGdebug) but not needed.

How does it works?

We monitor your app to determine the active screen at any given moment. For each screen, we maintain a record of events and tags that you have supplied, enabling us to place ads in those tagged views or during specific transitions and events from the record.

...