Banner

Is Banner Supported

Check if the platform supports displaying banner ads. Use this to determine if you can include banner advertisements in your game

bridge.advertisement.isBannerSupported

To enable banners on Game Distribution, add a <div> container of the required size in index.html and pass its identifier to ShowBanner. More about sizes: Game Distribution Wiki.

To ensure banners work on CrazyGames, you need to add a <div> container of the required size in your index.html file and pass its identifier to ShowBanner. For more details on the dimensions, refer to CrazyGames SDK documentation.

Show Banner

Display a banner ad within your game to generate revenue through advertising.

let options = { }

switch (bridge.platform.id) {
    case 'vk':
        options = {
            position: 'top', // optional parameter, default = bottom
            layoutType: 'resize', // optional parameter
            canClose: false // optional parameter
        }
        break
    case 'crazy_games':
        options = {
            containerId: 'div-container-id'
        }
        break
    case 'game_distribution':
        options = {
            containerId: 'div-container-id'
        }
        break
}

bridge.advertisement.showBanner(options)

Hide Banner

Hide the currently displayed banner ad when it is no longer needed.

bridge.advertisement.hideBanner()

Monitor the state of the banner ad (loading, shown, hidden, failed) to manage its display and troubleshoot issues.

bridge.advertisement.bannerState
// Listen for banner state changes
bridge.advertisement.on(bridge.EVENT_NAME.BANNER_STATE_CHANGED, state => {
    console.log('Banner state: ', state)
})

Possible values: loading, shown, hidden, failed.

Last updated