Question About Using a Singleton to Make Requests From Multiple Ad unit ID's

65 views
Skip to first unread message

ToneUK

unread,
Feb 10, 2014, 12:12:53 PM2/10/14
to google-adm...@googlegroups.com
I would like to create a singleton class which contains only one instance of an ad view. I would then like to switch the Ad unit ID when changing screens in my app. Is this possible without having to create multiple ad view instances?

I was just wondering if it is possible to do the following: 

1. Create a singleton class which contains a single ad view.
2. Create only one instance of the ad view using an Ad unit ID.
3. Create a request for this new ad view.
4. When changing screens, change the Ad unit ID of the ad view.

I have managed to code this up but I was just wondering if it is supported to switch the Ad unit ID of an already created ad view which is receiving adverts? Would changing the Ad unit ID require a new request to be called?

Also. How often can you make requests? Is it possible to make too many or does the SDK handle throttling when making requests?

Thanks


Eric Leichtenschlag

unread,
Feb 13, 2014, 12:54:12 PM2/13/14
to google-adm...@googlegroups.com
Hello,

The standalone SDK only lets you specify an ad unit ID in the constructor. In Google Play services, there is an AdView.setAdUnitId setter method, but I believe you'll get an IllegalStateException if you call that method twice. So the SDK is written in such a way to guide you to create a new AdView for different placements in your app.

The SDK doesn't do any throttling. But making requests too fast means you aren't showing the ad to your users for very long, which deflates CTR and eCPM, and also just consumes more data. Generally we recommend to set a refresh rate and let the SDK handle the refreshing for you. This way you'd only need to call loadAd once for each AdView you create.

Thanks,
Eric

ToneUK

unread,
Feb 14, 2014, 4:03:44 PM2/14/14
to google-adm...@googlegroups.com
Thanks for getting back to me on this Eric. I assumed you would be able to change the AdUnitId because the iOS AdMob SDK lets you do it. It also lets you change the size of the advert. I take it the same intention is meant for the iOS version as well. Not to be able to change the AdUnit or size once the AdView has been created?

Eric Leichtenschlag

unread,
Feb 18, 2014, 11:18:33 AM2/18/14
to google-adm...@googlegroups.com
You're right that the iOS SDK is not as explicit and actually lets you do this. It probably should be more explicit. I'll file a bug to add a logging message to iOS about this. I'm not keen on changing the behavior on iOS, only because some folks will just drop in the new SDK and see it compile and won't test the new behavior, and I'd prefer to avoid breaking existing implementations.

The expectation in general is that each placement should have a unique ad unit ID.

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages