Madex
  • Android SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • iOS SDK
    • Installing and configuring the SDK
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change Log
  • Unity Plugin
    • Installing and configuring the plugin
    • Working with advertising
    • User Consent Screen
    • Adapters for other SDKs
      • Applovin MAX SDK
      • IronSource SDK
    • Change log
  • Cordova Plugin
    • Installation and configuration the plugin
    • Working with advertising
    • Change Log
  • Construct3 Addon
    • Addon installation and configuration
    • Installation and configuration of Madex mediation addon
    • Working with advertising
Powered by GitBook
On this page
  • Identifiers from personal account
  • Publisher identifier (publisher_id)
  • Ad unit identifier (placement_name)
  • Test identifiers
  • Advertising Formats
  • Fullscreen Banner (Interstitial)
  • Rewarded Video
  • Banner 320x50
  • Plugin Methods
  • Using Multiple Ad Units
  • Tracking Ad Events
  1. Cordova Plugin

Working with advertising

General principle of interaction with ad units.

PreviousInstallation and configuration the pluginNextChange Log

Last updated 5 days ago

Identifiers from personal account

Publisher identifier (publisher_id)

To initialize the plugin you will need the publisher identifier (publisher_id)

Your publisher_id is located in the "Settings" section of your Madex personal account.

Ad unit identifier (placement_name)

When using plugin methods, you will need the ad unit identifier (placement_name) of the ad unit.

placement_name is the ID of the ad unit. Ad units are created in Madex personal account.

Test identifiers

During plugin integration, we recommend using special publisher_id and placement_name to get stable test ads.

Publisher ID - d42994c6-2145-4269-9c2f-2adcf9d9703f

International format

Madex Interstitial ID - 50f37030-162d-4e8c-a9c0-e078d8fbf2f7

IronSource Interstitial ID - 82e3bba6-6add-4594-8bb7-f96fef5b252d

Rewarded Video Format

Madex Rewarded ID - dacd566d-8487-4bc6-8afc-486f625be870

IronSource Rewarded ID - 42e716e1-91c0-47e0-9832-c36ada6fa836

Banner Format

Madex Banner ID - 901a609e-b9b2-4f82-b8b8-c899c5524867

Advertising Formats

The Madex advertising network supports 2 ad formats.

Fullscreen Banner (Interstitial)

The ad is displayed on the entire screen and contains a banner, interactive banner, or video. Tapping on it leads to a transition to the link specified by the advertiser.

Users can close the banner after 3 seconds.

This format is typically used when launching the application or transitioning between application screens.

When working with this format, use the Madex.INTERSTITIALparameter.

Here's an example method call to display this format of advertising.

Madex.showAd(Madex.INTERSTITIAL, "placement_name");

Rewarded Video

The ad is displayed on the entire screen and contains a video or interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

Users can stop viewing the ad, but in this case, they will see a dialog warning about the lack of a reward when closing the video before its completion.

When working with this format, use the Madex.REWARDED parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(Madex.REWARDED, "placement_name");

To determine whether to reward the user, use the onRewardedFinished event.

Banner 320x50

The ad is displayed at the bottom of the screen and contains an interactive banner. Tapping on it leads to a transition to the link specified by the advertiser.

When working with this format, use the Madex.Banner parameter.

Here's an example method call to display this format of advertising.

Madex.showAd(Madex.BANNER, "placement_name");

Auto-Refresh of Banner Ads

To increase your profits, we have developed a function for automatic content change in the banner.

To configure, specify the interval in seconds (minimum 10 seconds).

If the parameter is not filled in or equals zero, the content will not be updated.

const refreshIntervalSeconds = 10;
Madex.setBannerCustomSettings(_, __, refreshIntervalSeconds);

Banner Placement

By default, the banner is positioned at the bottom of the screen, but you can override this behavior.

Define the banner’s position using BannerSettings.

Bottom of the screen:

const bannerPosition = Madex.BANNER_POSITION_BOTTOM;
const refreshIntervalSeconds = 10;
Madex.setBannerCustomSettings(_, bannerPosition, refreshIntervalSeconds);

Top of the screen:

const bannerPosition = Madex.BANNER_POSITION_TOP;
const refreshIntervalSeconds = 10;
Madex.setBannerCustomSettings(_, bannerPosition, refreshIntervalSeconds);

Show close button

By default, the close banner button is not shown, but you can enable it:

const showCloseButton = true;
const bannerPosition = Madex.BANNER_POSITION_BOTTOM;
const refreshIntervalSeconds = 10;

Madex.setBannerCustomSettings(
  showCloseButton,
  bannerPosition,
  refreshIntervalSeconds
);

Plugin Methods

Working with ads involves working with Madex Plugin methods.

  1. initialize (required): Initializes the plugin . It's sufficient to call this method once at the application launch or before the first call to the loadAd method.

Madex.initialize("publisher_id");
  1. loadAd (required): Loads ads from the server. Usually, this method is called in advance so that the content is loaded by the time of the ad display. In this case, the user's waiting time for ad display will be minimal.

// Load Interstitial ad
Madex.loadAd(Madex.INTERSTITIAL, "placement_name");
// Load Rewarded video ad
Madex.loadAd(Madex.REWARDED, "placement_name");
// Load Banner ad
Madex.loadAd(Madex.BANNER, "placement_name");

  1. isAdLoaded (optional): Checks the ad unit loading status.

Madex.isAdLoaded(Madex.INTERSTITIAL, "placement_name");
Madex.isAdLoaded(Madex.REWARDED, "placement_name");
Madex.isAdLoaded(Madex.BANNER, "placement_name");

The method returns true or false. If the answer is negative, attempting to show the ad will lead to nothing.

Although the use of this method is optional, we strongly recommend checking the ad loading status before attempting to display it.

// Check the loading status and subsequently show the Interstitial ad
if (Madex.isAdLoaded(Madex.INTERSTITIAL, "placement_name")) {    
    Madex.showAd(Madex.INTERSTITIAL, "placement_name");
}

  1. showAd (required): Calls ad display using the player built into the SDK.

Madex.showAd(Madex.INTERSTITIAL, "placement_name");
Madex.showAd(Madex.REWARDED, "placement_name");
Madex.showAd(Madex.BANNER, "placement_name");

  1. destroyAd (optional): Destroys the ad container. You can work with multiple ad units simultaneously, but we strongly recommend destroying unnecessary ones to avoid memory issues and other problems.

// Destroy the Rewarded Video ad container
Madex.destroyAd(Madex.REWARDED, "placement_name");

  1. setUserConsent (optional): Intended for conveying the user's consent status for the collection, processing, and use of personal data. By default, it is set to false, meaning the user has not given consent to the use of their data for advertising and other purposes. We recommend using this method to improve ad monetization quality.

Using Multiple Ad Units

You can work with multiple ad units asynchronously, meaning you can call methods with different placement_names and formats independently of each other. For example, you can call the loadAd method for several blocks at once and load them concurrently.

Tracking Ad Events

Madex Plugin allows you to track events occurring with ads to use them for integrating ads into your application's logic.

To track events, you need to provide a class to work with.

Note that ad events work on any ad unit.

That is, if you call the loading of 2 ad units simultaneously, the loading event will work 2 times, once for each unit.

Here are examples of setting up existing advertising events.

window.addEventListener('onInterstitialLoaded', function (adInfo) {
    // Called when the ad is loaded
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onInterstitialLoadFailed', function (adInfo) {
    // Called if there is an error during ad loading
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onInterstitialShown', function (adInfo) {
    // Called when the ad is displayed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onInterstitialShowFailed', function (adInfo) {
    // Called if there is an error during ad display
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onInterstitialClosed', function (adInfo) {
    // Called when the ad is closed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onRewardedLoaded', function (adInfo) {
    // Called when the ad is loaded
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onRewardedLoadFailed', function (adInfo) {
    // Called if there is an error during ad loading
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onRewardedShown', function (adInfo) {
    // Called when the ad is displayed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onRewardedShowFailed', function (adInfo) {
    // Called if there is an error during ad display
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onRewardedClosed', function (adInfo) {
    // Called when the ad is closed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onRewardedVideoStarted', function (adInfo) {
    // Called when a video ad starts playing
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onRewardedVideoCompleted', function (adInfo) {
    // Called when the advertising video has completed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onUserRewarded', function (adInfo) {
    // Here you can reward the user
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onBannerLoaded', function (adInfo) {
    // Called when the ad is loaded
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onBannerLoadFailed', function (adInfo) {
    // Called if there is an error during ad loading
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onBannerShown', function (adInfo) {
    // Called when the ad is displayed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onBannerShowFailed', function (adInfo) {
    // Called if there is an error during ad display
    // Using adInfo, you can get detailed information about the request
    // You can obtain detailed error information using adInfo.error parameter
});
window.addEventListener('onBannerClosed', function (adInfo) {
    // Called when the ad is closed
    // Using adInfo, you can get detailed information about the request
});
window.addEventListener('onBannerImpression', function (adInfo) {
    // Recording the banner impression
    // Using adInfo, you can get detailed information about the request
});