Versions Compared

Key

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

...

Do iOS Get Started until finishing step 3.5

Step summary

  1. Add the initialization code.

  2. Add the ad wrapper views in your app.

  3. Follow our ad format guides for their implementation.

  4. Test everything is working.

  5. Change everything to production code.

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

We only mention how to create wrappers and not triggers because the way a trigger is fetch for its use is highly dependant on your specific app code.

Wrappers and Triggers/Events are used for different formats, each ad format page tells you what you need to use (wrapper or trigger) to display it.

Initialize the SDK

Note

We require the SDK to be initialized only once and as early as possible so for this purpose using the UIApplicationDelegate’s didFinishLaunchingWithOptions method or the first UIViewController’s viewDidLoad method is recomended.

...

It can be done either inside your UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) method or inside the first UIViewController.viewDidLoad() method.

Initialization inside the UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) delegate method.

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() // This is for testing purposes, remove it on prod
        // publisherId and appId are for testing purposes, remove it on prod
        R89SDK.shared.initialize(
          publisherId: "TestRefinery89ID",
          appId: "TestDemoApp",
          singleLine: false,
          publisherInitializationEvents: nil
        )
        return true
    }
}

...

Note

This appID is not the same GADApplicationIdentifier provided in the Info.plist in previous steps.

Add wrappers to your

...

views

Wrappers are the simple UIView containers container inside which the ads will show. You need to add as many ad slots or ad places as you desire. The wrapper can be linked from the

You can add the wrappers using XCode’s UI builder Builder or be created programmatically in the view controller.

Here is a short example that demonstrates the wrapper usage by creating it in the XCode’s UI Builder.

...

The adContainer is linked with the AdViewController, and provided to the RefineryAdFactory.shared.createBanner(...) method as a wrapper parameter.

Code Block
languageswift
class AdViewController: UIViewController {
    
    @IBOutlet var adContainer:UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID
        // Passing the adContainer wrapper to the SDK, so it can display a banner ad in it.
        RefineryAdFactory.shared.createBanner(wrapper: adContainer, 
                                              configurationID: configurationID,
                                              lifecycleCallbacks: nil)
    }
}

Now the ad will be placed inside the adContainer.

Here is the equivalent example that demonstrates how to create a wrapper programmatically and display an ad in it.

Code Block
languageswift
class AdViewController: UIViewController {
    
    let adContainer:UIView = {
        let view = UIView()
        view.translatesAutoresizingMaskIntoConstraints = false
        return view
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Add and center the adContainer in it's parent
        view.addSubview(adContainer)
        NSLayoutConstraint.activate([
           adContainer.centerXAnchor.constraint(equalTo: view.centerXAnchor),
           adContainer.centerYAnchor.constraint(equalTo: view.centerYAnchor),
        ])
         // Passing the adContainer wrapper to the SDK, so it can display a banner ad in it.
        RefineryAdFactory.shared.createBanner(wrapper: adContainer, 
                                              configurationID: ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID,
                                              lifecycleCallbacks: nil)
    }
}

Now the adContainer has been created programmatically. It is added and centered in its parent. In the next step, the instance of adContainer is provided to the RefineryAdFactory.shared.createBanner via wrapper argument, so the SDK will display the ad in it.

...

programmatically, for more see the iOS Creating a wrapper.

Follow our ad format guides.

Child pages (Children Display)
depth1
allChildrentrue
style
pageiOS - Ad Formats
sortAndReverse
first0

Go into production

  • 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.

How does it work?

We fetch all ad unit configurations from our Database and you simply need to place the ad units using the RefineryAdFactory and the r89ConfigurationIDs we provide you. Incorporate them into the desired views.

Check iOS - Ad Formats to see how each format is implemented.