Some GADUnifiedNativeAdViews Are Not Clickable (AdMob/Swift)
I am implementing AdMob’s Native Advanced ads into my iOS app. I use a UICollectionViewCell
that contains a GADUnifiedNativeAdView
and from there, I set up my ads in the viewDidLoad()
and cellForItemAt()
…
The Code
override func viewDidLoad() {
let adUnitID = "ca-app-pub-3940256099942544/3986624511"
let numAdsToLoad = 5
let options = GADMultipleAdsAdLoaderOptions()
options.numberOfAds = numAdsToLoad
let adOptions = GADNativeAdViewAdOptions()
adOptions.preferredAdChoicesPosition = .topRightCorner
adLoader = GADAdLoader(adUnitID: adUnitID, rootViewController: self, adTypes: [.unifiedNative], options: [options, adOptions])
adLoader.delegate = self
adLoader.load(GADRequest())
}
func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADUnifiedNativeAd) {
nativeAds.append(nativeAd)
}
func adLoaderDidFinishLoading(_ adLoader: GADAdLoader) {
collectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "onlineAdCell", for: indexPath) as! OnlineAdCollectionViewCell
let nativeAd = nativeAds[onlineAdIndex()]
nativeAd.rootViewController = self
(cell.adView.headlineView as! UILabel).text = nativeAd.headline
(cell.adView.callToActionView as! UILabel).text = nativeAd.callToAction
(cell.adView.imageView as! UIImageView).image = nativeAd.images?.first?.image
cell.adView.imageView?.contentMode = .scaleAspectFill
cell.adView.callToActionView?.isUserInteractionEnabled = false
cell.adView.nativeAd = nativeAd
return cell
}
The Problem
So this works almost perfectly. The problem is that, for whatever reason, only some of the ads are actually clickable. So here’s what a clickable ad looks like in my UI:
and here’s what a non-clickable ad looks like:
As you can tell the only difference is the ad info icon in the top right-hand corner.
Does anyone have any idea as to why this would be happening and any troubleshooting solutions? It’s quite confusing…
Source: Ios