我已经实现了 FBNativeAdsManager ,以便在表格视图中显示Facebook原生广告。广告显示正常,但点击事件不起作用。代表们也没有工作。
以下是已实现的代码:
class func initiateAdvtView() -> AdvtView {
let popUp = UINib(nibName: "AdvtView", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! AdvtView
popUp.configureAdManagerAndLoadAds()
return popUp
}
func prepareUI() {
prepareFBAds()
}
{
func nativeAdsLoaded() {
prepareFBAds()
] 2}
func nativeAdDidLoad(_ nativeAd: FBNativeAd) {
kprint("nativeAdDidLoad")
}
func nativeAdsFailedToLoadWithError(_ error: Error) {
print(error)
}
func nativeAdDidClick(_ nativeAd: FBNativeAd) {
kprint("Done")
}
func nativeAdDidFinishHandlingClick(_ nativeAd: FBNativeAd) {
kprint("nativeAdDidFinishHandlingClick")
}
func prepareFBAds() {
guard adsManager != nil else {
return
}
if let ad = adsManager.nextNativeAd {
ad.delegate = self
message.text = ad.bodyText
title.text = ad.advertiserName
message.nativeAdViewTag = FBNativeAdViewTag.body
title.nativeAdViewTag = FBNativeAdViewTag.title
ad.adChoicesIcon?.loadAsync(block: { (iconImage) in
if let image = iconImage {
self.postImage.image = image
}
})
ad.registerView(forInteraction: self, mediaView: coverMediaView, iconImageView: postImage, viewController: nil, clickableViews: [callToActionButton, message, title, postImage, postView])
}
}
func configureAdManagerAndLoadAds() {
adsManager = FBNativeAdsManager(placementID: fbPlacementID, forNumAdsRequested: 1)
adsManager.delegate = self
adsManager.loadAds()
}
}
我花了很多时间使点击功能正常运行,但没有成功。如果有人有使用FBNativeAds的经验,请帮助我。
谢谢!