I have successfully got a cordova project running with admob-plus plugin in Android Studio. The banners work perfectly on various pages. Google Play has rejected the app because banners are visible on the embedded YouTube pages. I would like to change this and make them invisible on these pages. My question: How can I make a banner invisible on pages with YouTube videos? The banners appear automatically and are above the iframe. My attempts with additional iFrames and z-index always show the admob banner. Even links to external html pages with YouTube videos always show the banner that is superimposed on top. How can I make the banner invisible directly on the pages?
In the header of the html pages I have linked to cordova.js and admob.js and then added these snippets with the corresponding AdUnitID:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="plugins/admob-plus-cordova/www/admob.js"></script>
<script>
let banner
document.addEventListener('deviceready', async () => {
banner = new admob.BannerAd({
adUnitId: 'ca-app-pub-xxx/yyy',
})
banner.on('impression', async (evt) => {
await banner.hide()
})
await banner.show()
}, false)
</script>
On the html page with embedded Youtube iframe I used the snippet, which does not hide the banner:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="plugins/admob-plus-cordova/www/admob.js"></script>
<script>
document.addEventListener('deviceready', async () => {
// Obtain user consent first
await admob.hide() // or start loading ads
// Load ads here
}, true)
Is it not possible to do this directly on the corresponding html page? Do I have to add the MainActivity.java so that I can hide the banner on the YouTube page? I have been looking for a solution for days and would be very grateful for any help.
MainAcitivity.java
package ...
import ...
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}