Clarification of some questions about AdMob

Hello everyone Perhaps this has already been discussed somewhere, I searched, but did not find enough information. It is scattered somewhere in pieces. I have a vague picture on this issue. I would like someone to just clarify the situation(helped me put the puzzle together):

  1. In order to display the reward and interstitial ads, do I have to download them in advance? And if in advance, where? In the main file, or another one? I would really like to just see: which code is in main, which is in scene.
  2. To test the ad, I have to set testmod=true. But where? I would be extremely grateful if someone would show examples with the code. Thank you in advance!

Loading the ads is done with admob.load() The basics of the entire process can be seen in the sample code for admob.show() in the documentation.

To put yourself into test mode, add the testMode flag to your init parameters like this:

admob.init( adListener, { testMode = true )

The documentation is a little outdated; you no longer put your app ID in the init params. It goes in your build.settings file:

For Android, it goes here:

applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="ca-app-pub-YOUR APP ID HERE"/>  -- See: https://goo.gl/fQ2neu
            ]],
        },

And for iOS, it is part of the plist:

GADApplicationIdentifier = "ca-app-pub-YOUR APP ID HERE",

What about rewarded ads? I understand that it is necessary to produce the “init” stage in “main”, and the “isLoaded” and "show"phase directly on the stage. As I understand it, ads should always be loaded in advance, but in my app, all the phases go on a certain scene. Should I fix this?
And does it work for both interstitial and rewards, or are there certain features?

It isn’t necessary to initialise the plugin in main.lua. In fact, I would recommend that you create a separate “ads.lua” module that contains all AdMob related code.

You can require this ads module from main and start the initialisation as soon as the app starts, but you would also be able to require the module in other scenes and handle function callbacks easier this way.