AdMob is a mobile ad platform provided by Google. Using AdMob ads in your app can be an easy way to monetize on your app without selling it as a paid app or using micro-transactions.
Setting up an AdMob account requires a few different steps, but once setup it is very easy to implement into your app.
If you already have an AdMob account, please continue with step 2.
Once you have your AdMob account set up, you are ready to create Ad Units. An Ad Unit can be either a banner or a fullscreen (Interstitial) ad that will play a movie.
You can choose if you would like to use either or both.
One Ad Unit for each format has to be created for each platform your app will run on (iOS / Android).
Create these Ad-Units via these steps:
You will now see a list of your two ad units, the ID for these ad units will later be used when you are implementing ads in your app, so copy them somewhere and save them.
Repeat all of the above steps for your iOS app as well.
Once you have generated Ad units for your ads, you are now ready to implement these ads in your app. This is done by first initializing the AdMob settings by using the Device.AdMob.Init coding block and then show the banner by using the Device.AdMob.Banner.Create or by showing an interstitial ad by using the Device.AdMob.Interstitial.LoadAndShow.
First, initialize your AdMob by using the Device.AdMob.Init coding block by editing the Loaded-script on your MasterPage. Do this by following these steps:
When that is done, save your MasterPage and you are ready to start using ads.
To show a banner in your app, use the Device.AdMob.Banner.Create coding block to show an interstitial ad by using the Device.AdMob.Interstitial.LoadAndShow
Please note that after you've added ads to your app - it might take a few hours before they start to show up. If you would like to test that the ads you can set 'Yes' as value to the TestMode parameter which will will show test ads in your app. Do not forget to change this back after you are done testing.
The following Visual Coding blocks can be used to use manage ads in your app:
Device.AdMob.Banner.Create
Creates a banner view where the banner will be shown. The bannerview will be created in the bottom of the page. If you would like the banner to be shown in the top of your page instead, please have a look at the documentation for the Device.AdMob.Init block.
Parameters:
None
Return values:
ErrorMessage (Value) - Error if something went wrong
Outlets:
Done - Called when the block is done
Failed - Called if something went wrong
Device.AdMob.Banner.Hide
Temporarily hides the banner from the app.
Parameters:
None
Return values:
ErrorMessage (Value) - Error if something went wrong
Outlets:
Done - Called when the block is done
Failed - Called if something went wrong
Device.AdMob.Banner.Remove
Removes the banner view from the app. To view the banner again, use the Device.AdMob.Banner.Create block
Parameters:
None
Return values:
ErrorMessage (Value) - Error if something went wrong
Outlets:
Done - Called when the block is done
Failed - Called if something went wrong
Device.AdMob.Banner.Init
Initilizes the admob features. This must be run before using AdMob.
Parameters:
Android_BannerId (Value) - Ad-unit ID for the Android banner format
Android_InterstitialId (Value) - Ad-unit ID for the Android interstitial format
iOS_BannerId (Value) - Ad-unit ID for the iOS banner format
iOS_InterstitialId (Value) - Ad-unit ID for the iOS interstitial format
TestMode (Value) - Set to Yes to use testing ads
BannerPosition (Value) - Set to Top to get the banner on the top of the window, all other values will put the banner in the bottom.
Return values:
ErrorMessage (Value) - Error if something went wrong
Outlets:
Done - Called when the block is done
Failed - Called if something went wrong
You can always use your own custom JavaScript code to work with the AdMob library.
Aquro is using the cordova-plugin-admob-free Cordova plugin for this device feature.
More documentation and code examples for this plugin can be found here:
https://github.com/ratson/cordova-plugin-admob-free