FBNativeAd点击事件

时间:2019-04-09 18:16:13

标签: ios swift facebook

我已经实现了 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()

Facebook Ads[![][1]] 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的经验,请帮助我。

谢谢!

0 个答案:

没有答案