fbsamples / audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
https://developers.facebook.com/docs/audience-network
Other
319 stars 370 forks source link

Facebook native Ads are not clickable again in UITableView Cells after scroll #68

Closed saurabh1939 closed 6 years ago

saurabh1939 commented 6 years ago

I have implemented facebook native Ads in UITableView, for first 1-2 times it clickable but when I scroll tableview and come again back to the same cell, now Ads are not clicking, I am using swift 3.2 Below is the cell implementation.

let ad = adsManager.nextNativeAd let cell = self.tableHome.dequeueReusableCell(withIdentifier: "HomeAdsTableViewCell", for: indexPath) as! HomeAdsTableViewCell cell.message.text = ad?.body cell.title.text = ad?.title cell.callToActionButton.setTitle(ad?.callToAction, for: .normal)

if let pic = ad?.coverImage { cell.postImage.setImageWithIndicator(imageUrl:pic.url.absoluteString) }

ad?.registerView(forInteraction: cell.postView, with: self) cell.selectionStyle=UITableViewCellSelectionStyle.none

return cell

andrliu commented 6 years ago

Hi @saurabh1939, I feel the issue you have here is about reusable cell. Would you be able to provide us a sample code which could reproduce the issue. Thanks.

saurabh1939 commented 6 years ago

i followed mentioned tutorial link : https://friendlyublog.com/implementing-native-facebook-ads-for-ios-apps-9dc4174ae1a3

andrliu commented 6 years ago

If you are interested in how to use FBNativeAdsManager, you might want to check out our AdUnitsSample. You can get the sample app with from our SDK download link, https://developers.facebook.com/docs/audience-network/download#ios. It should have the most updated implementation.

saurabh1939 commented 6 years ago

Above sample is in Objective C, Can i get it in Swift ?

andrliu commented 6 years ago

Unfortunately, we only have sample in ObjC. If you look at TableViewController, it is not so hard to do it in Swift.