Rewarded
Integration
Just as interstitials, rewarded ads can only be integrated with code. Below we show a simple example to understand how it works:
import UIKit
import WortiseSDK
class ViewController: UIViewController {
private var rewardedAd: WARewardedAd!
override func viewDidLoad() {
super.viewDidLoad()
...
rewardedAd = WARewardedAd(adUnitId: "test-rewarded")
rewardedAd.loadAd()
}
override func willMove(toParent controller: UIViewController?) {
super.willMove(toParent: controller)
...
rewardedAd.destroy()
}
func showRewarded() {
if rewardedAd.isAvailable {
rewardedAd.showAd(from: self)
}
}
}Delegate configuration
Like occurs with other formats, a listener can be set to receive the events that happen during the rewarded lifecycle. For this, it is needed to implement the WARewardedDelegate interface just as shown in the example below:
Once the interface is implemented, the delegate is assigned to the ad instance:
Última actualización