Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 10 Next »

Prerequisites

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.

Initialize the SDK

We require the SDK to be initialized only once and as early as possible It can be done either inside your UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) method or inside the first UIViewController.viewDidLoad() method.

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

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",
            appId: "TestAppId",
            singleLine: true,
            publisherInitializationEvents: nil)
        return true
    }
}

Your publisherId and appId will be provided to you during onboarding process by email, you can also retrieve them from the web interface after login.

This appID is not the same as the Manifest App Id you 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.

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

Events

Events can trigger other formats, right now the single tag supports:

  • Transition events are detected by the single tag automatically after initialization. They happen when a UIViewController is started/presented from another UIViewController.

  • Button Presses when a button is pressed, this works They are detected by adding the android:tag attribute to the button.

Example of transition:

 

In this example an interstitial would be triggered when we see the NewsPostDetailActivity comes to live after loading.


Example of button press:

 

In this example an interstitial would be triggered when the button is pressed and when the interstitial is closed the playVideoTrailer() method will be executed.


Adding testing single tag data

Go back to the UIViewController 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 initialization method we called addTestingSingleTagData() that uses the SingleTagConfigBuilder to create the testing data needed for debugging the sdk.

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

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.

func addTestingSingleTagData(){

SingleTagConfigBuilder.shared.addAdScreenBuilder(isFragment:false,screenName: "InitialScreenViewController")
    .addBanner(wrapperTag: "banner_tag",
               getAllWithTag: true,
               wrapperRelativePositionInside: true,
               wrapperRelativePositionAfter: false)
    .addInterstitial(eventsToTrackTo: nil, eventsToTrackButton: "button_tag")
    .addInterstitial(eventsToTrackTo: "SecondSCreenViewController", eventsToTrackButton: nil)
}

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

For going into production you will need to use you ids:

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

  • Change the App id in the info.plist for the production one

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

  • it’s also recommended to remove R89SDK.shared.setLogLevel(LogLevels.DEBUG) 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.

We have the capability to display Display ads on a tagged wrappers or trigger an Interstitial ads during the transition from one screen to another or in button press. And many other things All of this can be achieved without the need of coding specific triggers or manually adding the ad to the view. It is as simple as initializing the SDK.

  • No labels