IOS - SDK-dokumentation för att tjäna pengar på appen

⌘K
  1. IOS - Tjäna pengar på app-SDK:t Gör...
  2. Användarmanual
  3. Skapa en omslutning

Skapa en omslutning

The SDK uses the wrapper to put the ad in it. The wrapper is a UIView from the UIKit framework, the UIView can be linked from the XCode’s UI 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.

Den annonsbehållare is linked with the AdViewController, and provided to the RefineryAdFactory.shared.createBanner(...) method as a förpackning parameter.

    class AdViewController: UIViewController {
        @IBOutlet var adContainer:UIView!
        override func viewDidLoad() {
            super.viewDidLoad()
            let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID
            RefineryAdFactory.shared.createBanner(
            configurationID: configurationID,
            wrapper: adContainer,
            lifecycleCallbacks: nil)
        }
    }
    

Now the ad will be placed inside the annonsbehållare.

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

        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),
                ])
                // Provide the adContainer as a wrapper parameter
                let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID
                RefineryAdFactory.shared.createBanner(configurationID: configurationID,
                wrapper: adContainer, lifecycleCallbacks: nil)
            }
        }
    

Now the annonsbehållare has been created programmatically. It is added and centered in its parent. The next step is the same, the instance of annonsbehållare is provided to the RefineryAdFactory.shared.createBanner via förpackning argument, so the SDK will display the ad in it.

Artiklar

Hur kan vi hjälpa till?