Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob Native Expess Ads blocks while scrolling in UICollectionView

I currently have an Admob Native Express Ad (GADNativeExpressAdView) configured in a UICollectionViewCell.

  • I used the storyboard to set it up by adding an empty view and assigning the GADNativeExpressAdView class to it.
  • Everything loads up fine and an ad appears every 10 cells for example.

Problem: The first time the user opens the app and starts scrolling down the list of cells, when they reach the Ad cell, the scrolling blocks until the Native Ad is "built". Once it's done, scrolling continues. The ad then might take a moment (1-2 seconds) to load up the ad request.

  • The loading request does not seem to be the culprit.
  • I've also setup the ad programmatically, and it seems to mainly hang when I add the ad view as a subview of the cell the first time.

Let's say an ad should appear in cell #20, #30, etc, the second time (and every other one after that), the scrolling is uninterrupted. It only happens for the first one.

Any ideas on how to fix this would be really appreciated. Is this a problem with GADNativeExpressAdView itself?

Thank you.

AdCollectionViewCell.Swift

class AdCollectionViewCell: UICollectionViewCell {

    @IBOutlet var intercellBanner: GADNativeExpressAdView!

    override func awakeFromNib() {
        super.awakeFromNib()

        let request = GADRequest()
        request.testDevices = [kGADSimulatorID]
        self.intercellBanner.loadRequest(request)
    }

    override func prepareForReuse() {
        super.prepareForReuse()

        let request = GADRequest()
        request.testDevices = [kGADSimulatorID]
        self.intercellBanner.loadRequest(request)

    }
}
like image 382
user1202888 Avatar asked Jun 15 '16 22:06

user1202888


People also ask

What are Google AdMob native ads?

Google AdMob Native Ads Playbook - Google AdMob Native ads allow you to customize the ads that appear in your app. Learn the best practices and why you should be using native ads for your app. Native ads allow you to customize the ads that appear in your app. Learn the best practices and why you should be using native ads for your app.

What should native ads look like?

While native ads allow you to customize the ad design the way you want, below are a few general rules of thumb to follow when you’re deciding how your native ads will look: 1. Match the ad design with the look and feel of your app’s content. Align elements and use similar fonts, colors, and styles.

How do I load ads in AdMob?

There are two methods available for this: loadAd () and loadAds (). Note: The loadAds () method currently works only with AdMob ads. For mediated ads, use loadAd () instead.

How do I load native ads using the SDK?

Broadly speaking, there are two parts to successfully implementing Native Ads: loading an ad via the SDK and displaying the ad content in your app. This page is concerned with using the SDK to load native ads . Import the Google Mobile Ads SDK, either by itself or as part of Firebase.


1 Answers

I wrapped line where request is loading with GCD async block and it looks like this approach solved scrolling issue.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
    view.nativeExpressAdView.loadRequest(request)
})
like image 192
Shyngys Kassymov Avatar answered Oct 04 '22 23:10

Shyngys Kassymov