AdMob plugin test mode question

Getting the following messages in my log from IOS Simulator following the docs:
 

Feb 28 01:31:33.720 [iOS Simulator] adListener init

Feb 28 01:31:33.759 [iOS Simulator] adListener load and show

Feb 28 01:31:33.779 [iOS Simulator] plugin.admob: Test mode active for device ‘516c41f684c6a54071e188f0bf7dbd0e’

Feb 28 01:31:34.825 [iOS Simulator] <Google> To get test ads on this device, call: request.testDevices = @[kGADSimulatorID];

Feb 28 01:31:36.757 [iOS Simulator] adListener loaded

Feb 28 01:31:36.779 [iOS Simulator] ad shown

Feb 28 01:31:36.837 [iOS Simulator] adListener displayed

Feb 28 01:31:37.785 [iOS Simulator] adListener failed

What is the correct way to provide this device number property to the AdMob calls? .init(), .load(), .show() give the error

Invalid option ‘testDevices’

when I add

,&nbsp;testDevices={"516c41f684c6a54071e188f0bf7dbd0e"}

The adListener messages are printed event.phase values.

Without testmode, ads display on Android devices with the same code - but not in the IOS Simulator. I want to verify that ads are shown before I update the Iphone app.

Thanks,

Henrik

Here’s the code.

admob = require( "plugin.admob" ) function showad(event)&nbsp; -- Sometime later, show the interstitial ad if ( admob.isLoaded( "banner" ) ) then &nbsp; &nbsp; &nbsp; &nbsp; admob.show("banner", {y=-52}) print("ad shown") end end -- AdMob listener function local function adListener( event ) &nbsp; print("adListener",event.phase) &nbsp; &nbsp; if ( event.phase == "init" ) then &nbsp;-- Successful initialization &nbsp; &nbsp; &nbsp; &nbsp; -- Load an AdMob banner ad &nbsp; &nbsp; &nbsp; &nbsp; print("adListener load and show") &nbsp; &nbsp; &nbsp; &nbsp; admob.load( "banner", { adUnitId=myAppID } ) &nbsp; &nbsp; end &nbsp; &nbsp; if ( event.phase == "loaded" ) then&nbsp; &nbsp; &nbsp; showad(event) &nbsp; &nbsp; end end -- Initialize the AdMob plugin admob.init( adListener, { appId=myAppID, testMode=true } ) print("admob init called")

Hi Henrik,
 

What is the correct way to provide this device number property to the AdMob calls?

There is no such way, actually, since it already been done automatically.

Lets look at this line:

Test mode active for device '516c41f684c6a54071e188f0bf7dbd0e'

What’s interesting is that this log message is sending right after request.testDevices method have been called. So if you can see that log message, it means that your generated device id was already been sent to Google.
And the most interesting part of this whole situation is that even if your generatedDeviceId is somehow corrupt - the mentioned _kGADSimulatorID _is basically a Google Admob’s own constant that should work for any device universally.

Now, if I understand you correctly, you can’t get test ads for iOS simulator, am I right?
The trouble is I’ve just tested everything out and for me everything works as expected in testMode.

We can go two paths right now:

  1. ​You can give us some sample to reproduce the mentioned issue. Bug submission at https://portal.coronalabs.com/bug-submission is the most convenient way;
  2. You can test attached sample project and if the problem persists - we’ll start from there. Test ads  should work in test mode.

Of course, the first way is the fastest one, we can eliminate the issue (if it’s possible from Corona side) pretty quick if we can reproduce it. Although it could be tedious for you to prepare a sample, so it’s up to you to decide which path to choose.  :wink:

Thx Karpovpv! 

  1. The code I posted reproduces the issue here.

  2. Your example shows no ad until I click Hide until PHASE: is hidden, after which a click on Top, Bottom, Under line displays it.

I will look at your code and try to get something out that loads a banner ad on app start, thanks again.

I posted this in case I do something “wrong”, but that’s hard to know since documentation is lacking. It’s mostly down to testing and trying. So my code is the non-working Interstitial example in docs modified to work with Interstitials and then modded to load banners. I have no idea if it’s correct to .show() an ad just because the adListener got the “loaded” phase. It just seemed the proper thing to do, and better than to assume that “sometime later”, the ad is guaranteed to be loaded.

One reason for the question was also that activating testmode gave me that imperative from Google above, so with no ad showing naturally I assumed I had to somehow do what it told me.

Hi Henrik,
 

  1. The code I posted reproduces the issue here.

Well, the thing is that it doesn’t for me. I’ve requested a sample, because it’s important to see the exact sources that are causing this issue on your side, to quickly find what’s wrong with sources, since for now we cannot reproduce mentioned issue on our side. Also, you’ve mentioned interstitials absence, but your code above is all about banners. If you can submit a bug on https://portal.coronalabs.com/bug-submission with a sample to reproduce it, I highly recommend doing so - the problem can be solved as soon as we can find it.

So the ads are showing correct with my sample? Not sure that I understand you correctly about hide phase. You should just wait for the sdk to init and then load and show an ad with no problem.

If you can show an ad in my sample, but not on your app or test project - then it looks like something is wrong on Admob’s part or your app ID settings, can’t comment more on that, only Admob’s support team can help with that. You can write them straight away, but I’d suggest one more time for a bug submission, maybe we can find what’s wrong with your particular case fast enought.

A brief history of events is I got Interstitials to work in another app, but taking that code and changing it to banner resulted in event.phase=“failed”. 

Looking at your example, it seems I get some info from the event object that could pinpoint the problem. 

I’ve rigged your example to init, load, and show a banner ad, and it works. The only difference I can find is the individual adUnitIDs per banner type. I will check that I have current and correct IDs.

Edit: the adUnitID was current and correct, and set up for banners and interstitials.

OK, your example worked with our IDs. Copying the calls to my app shows the ad in test mode, and made me write two conclusions.

It is indeed possible to call .show() from the listener, but the gotcha is that doing it as a response to event.phase==“loaded” only works for Interstitials. 

For banner ads, you must respond to event. type ==“banner”, and apparently this omits having to check if it’s loaded first.

Thanks again for this example! :slight_smile: I’m not sure I would have reached this conclusion even if I’d come up with dumping out the event objects and trying to deduce how to respond to the event values on my own.

No problem, glad that you’ve figured everything out by yourself!

As always, feel free to share your questions and concerns here on forum - it’s easier to solve them together.  B)

Here’s the code.

admob = require( "plugin.admob" ) function showad(event)&nbsp; -- Sometime later, show the interstitial ad if ( admob.isLoaded( "banner" ) ) then &nbsp; &nbsp; &nbsp; &nbsp; admob.show("banner", {y=-52}) print("ad shown") end end -- AdMob listener function local function adListener( event ) &nbsp; print("adListener",event.phase) &nbsp; &nbsp; if ( event.phase == "init" ) then &nbsp;-- Successful initialization &nbsp; &nbsp; &nbsp; &nbsp; -- Load an AdMob banner ad &nbsp; &nbsp; &nbsp; &nbsp; print("adListener load and show") &nbsp; &nbsp; &nbsp; &nbsp; admob.load( "banner", { adUnitId=myAppID } ) &nbsp; &nbsp; end &nbsp; &nbsp; if ( event.phase == "loaded" ) then&nbsp; &nbsp; &nbsp; showad(event) &nbsp; &nbsp; end end -- Initialize the AdMob plugin admob.init( adListener, { appId=myAppID, testMode=true } ) print("admob init called")

Hi Henrik,
 

What is the correct way to provide this device number property to the AdMob calls?

There is no such way, actually, since it already been done automatically.

Lets look at this line:

Test mode active for device '516c41f684c6a54071e188f0bf7dbd0e'

What’s interesting is that this log message is sending right after request.testDevices method have been called. So if you can see that log message, it means that your generated device id was already been sent to Google.
And the most interesting part of this whole situation is that even if your generatedDeviceId is somehow corrupt - the mentioned _kGADSimulatorID _is basically a Google Admob’s own constant that should work for any device universally.

Now, if I understand you correctly, you can’t get test ads for iOS simulator, am I right?
The trouble is I’ve just tested everything out and for me everything works as expected in testMode.

We can go two paths right now:

  1. ​You can give us some sample to reproduce the mentioned issue. Bug submission at https://portal.coronalabs.com/bug-submission is the most convenient way;
  2. You can test attached sample project and if the problem persists - we’ll start from there. Test ads  should work in test mode.

Of course, the first way is the fastest one, we can eliminate the issue (if it’s possible from Corona side) pretty quick if we can reproduce it. Although it could be tedious for you to prepare a sample, so it’s up to you to decide which path to choose.  :wink:

Thx Karpovpv! 

  1. The code I posted reproduces the issue here.

  2. Your example shows no ad until I click Hide until PHASE: is hidden, after which a click on Top, Bottom, Under line displays it.

I will look at your code and try to get something out that loads a banner ad on app start, thanks again.

I posted this in case I do something “wrong”, but that’s hard to know since documentation is lacking. It’s mostly down to testing and trying. So my code is the non-working Interstitial example in docs modified to work with Interstitials and then modded to load banners. I have no idea if it’s correct to .show() an ad just because the adListener got the “loaded” phase. It just seemed the proper thing to do, and better than to assume that “sometime later”, the ad is guaranteed to be loaded.

One reason for the question was also that activating testmode gave me that imperative from Google above, so with no ad showing naturally I assumed I had to somehow do what it told me.

Hi Henrik,
 

  1. The code I posted reproduces the issue here.

Well, the thing is that it doesn’t for me. I’ve requested a sample, because it’s important to see the exact sources that are causing this issue on your side, to quickly find what’s wrong with sources, since for now we cannot reproduce mentioned issue on our side. Also, you’ve mentioned interstitials absence, but your code above is all about banners. If you can submit a bug on https://portal.coronalabs.com/bug-submission with a sample to reproduce it, I highly recommend doing so - the problem can be solved as soon as we can find it.

So the ads are showing correct with my sample? Not sure that I understand you correctly about hide phase. You should just wait for the sdk to init and then load and show an ad with no problem.

If you can show an ad in my sample, but not on your app or test project - then it looks like something is wrong on Admob’s part or your app ID settings, can’t comment more on that, only Admob’s support team can help with that. You can write them straight away, but I’d suggest one more time for a bug submission, maybe we can find what’s wrong with your particular case fast enought.

A brief history of events is I got Interstitials to work in another app, but taking that code and changing it to banner resulted in event.phase=“failed”. 

Looking at your example, it seems I get some info from the event object that could pinpoint the problem. 

I’ve rigged your example to init, load, and show a banner ad, and it works. The only difference I can find is the individual adUnitIDs per banner type. I will check that I have current and correct IDs.

Edit: the adUnitID was current and correct, and set up for banners and interstitials.

OK, your example worked with our IDs. Copying the calls to my app shows the ad in test mode, and made me write two conclusions.

It is indeed possible to call .show() from the listener, but the gotcha is that doing it as a response to event.phase==“loaded” only works for Interstitials. 

For banner ads, you must respond to event. type ==“banner”, and apparently this omits having to check if it’s loaded first.

Thanks again for this example! :slight_smile: I’m not sure I would have reached this conclusion even if I’d come up with dumping out the event objects and trying to deduce how to respond to the event values on my own.

No problem, glad that you’ve figured everything out by yourself!

As always, feel free to share your questions and concerns here on forum - it’s easier to solve them together.  B)