我正在将 SDK HeyZap 集成到 iOS 应用程序上。
我可以 fetch() 和 show() 一个 IncentivizedAd。
但我不能使用回调委托函数。
这三种方法对我不起作用(通知、完成(HZIncentivizedAd.ShowWithOptions),以及在我的班级上声明的 HZAdsDelegate、HZIncentivizedAdDelegate。
class GridLigueController: MyViewController, UITableViewDataSource, HZAdsDelegate, HZIncentivizedAdDelegate {
func didShowAdNotificationHandler() {
print("didShowAdNotificationHandler")
}
// Configure with NSNotification Listener
// function called on viewDidLoad
func configureRewardVideo() {
HZIncentivizedAd.setDelegate(self)
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(didShowAdNotificationHandler), name:HZMediationDidShowAdNotification, object:nil)
if adRequestInProgress == false && HZIncentivizedAd.isAvailable() == false {
HZIncentivizedAd.fetch()
adRequestInProgress = true
print("[Debug] - adRequestInProgress...")
} else {
print("[Debug] - Reward video not ready : \(adRequestInProgress)")
}
// Completion on showWithOptions
func completion(success: Bool, error: NSError!) -> Void {
if success {
print("success showing an ad")
} else {
print("error showing an ad; error was %@",error)
}
}
func showAd() {
if HZIncentivizedAd.isAvailable() {
let options = HZShowOptions()
options.viewController = self
options.completion = self.completion
HZIncentivizedAd.showWithOptions(options)
print("[Debug] - HZIncentivizedAd video is ready, should be shown")
} else { // show an alert }
}
// Normal Delegate function
func didReceiveAdWithTag(tag: String!) {
print("didReceiveAdWithTag")
}
func didShowAdWithTag(tag: String!) {
print("didShowAdWithTag")
}
func didFailToCompleteAdWithTag(tag: String!) {
print("didFailToCompleteAdWithTag")
}
func didCompleteAdWithTag(tag: String!) {
print("didCompleteAdWithTag")
}
}
我忘记了要初始化的东西吗?我使用 Xcode 7.3.1 和 Swift 2.3
谢谢你帮助我