Skip to content

Latest commit

 

History

History
105 lines (85 loc) · 3.31 KB

File metadata and controls

105 lines (85 loc) · 3.31 KB

banner ads

Banner advertisements which display at the bottom of the app screen.

jump to: banner | removeBanner | Example


banner ad

adMob.banner(banner_id, ad_size, ad_position)

Usage:

adMob.banner(banner_id,adMob.ad_sizes.RESIZE,adMob.ad_positions.BOTTOM).then(function () {
    // do anything after banner has loaded successfully
}).catch (function(err){
    // view or handle error messages
});

Description:

  • show a banner ad at the top or bottom of the app screen
  • by default the ad size is "banner", 320x50, and the ad position is at the bottom of the screen
  • use after the start up of the device (onDeviceReady)

Parameters:

  • Google AdMob id - for a banner ad
    can be "test" for test ads, or normally an ad string ("ca-app-pub-4029587076166791/6431168058"), or an ad_id object:
var admob_ids = {
    'android' : {
        'banner': "ca-app-pub-4029587076166791/6431168058",
        'interstitial': "ca-app-pub-4029587076166791/1370413062",
        'rewarded': "ca-app-pub-4029587076166791/9712771663",
        'rewardedInterstitial': "ca-app-pub-4029587076166791/3530506691"
    }, 'ios' : {
        'banner': "ca-app-pub-4029587076166791/6694891931",
        'interstitial': "ca-app-pub-4029587076166791/2436352227",
        'rewarded': "ca-app-pub-4029587076166791/5286441495",
        'rewardedInterstitial': "ca-app-pub-4029587076166791/2300620853"
    }
};
  • ad_size (optional - select a banner size, default is BANNER)`
    • adMob.ad_sizes.RESIZE resizes to the get the largest fitting available banner
    • adMob.ad_sizes.BANNER default 320x50 ad banner
    • adMob.ad_sizes.LARGE_BANNER 300x100
    • adMob.ad_sizes.MEDIUM_RECTANGLE 300x250
    • adMob.ad_sizes.FULL_BANNER 468x60
    • adMob.ad_sizes.LEADERBOARD 728x90
  • ad_position (optional - select a banner position, default is BOTTOM)`
    • adMob.ad_positions.BOTTOM default
    • adMob.ad_positions.TOP

Errors:

- error["description"]      //short description about where the error is coming from 
- error["name"]             //name of the error (LOAD_AD_ERROR, SHOW_AD_ERROR, INVALID_ARGUMENTS, etc.) 
- error["message"]          //error message, more information about the error
- error["responseCode"]     //ad error response code from Google (if there is one)
- error["responseMessage"]  //ad error response message from Google (if there is one)

common error names:

  • LOAD_AD_ERROR may occur when an ad id is not reconized or not ready to show ads yet

Tips:

  • call this again if it fails
  • banners overlap the main view, except for the top banner in Android

adMob.removeBanner()

Usage:

adMob.removeBanner().then(function () {
    // do anything after banners were removed
}).catch (function(err){
    // view or handle error messages (uncommon)
});

Description:

  • remove the banner ad
  • use after a call to banner if you wish to remove it

Parameters:

  • none needed

Example

function onDeviceReady() {
    adMob.banner(banner_id,adMob.ad_sizes.RESIZE).catch(function(err){});
}

go to main