Skip to content

XMediator::Api::Banner

This class represents a Banner Ad format.

Inherits from IDisposable

Public Types

Name
enum class Position { Top = 0, Bottom}
Enum class representing the available positions where a banner can be placed.
enum class Size { Phone = 0, Tablet = 1, MREC = 2}
Enum class representing the available sizes that a banner can be created with.

Public Events

Name
Action< PrebiddingResults > OnPrebiddingFinished()
Notifies when the prebidding call finished, containing a PrebiddingResults object.
Action< LoadResult > OnLoaded()
Notifies when the banner was loaded successfully, containing a LoadResult object. This callback can be called multiple times, due to the banner autorefresh triggering more loads.
Action< LoadError, LoadResult > OnFailedToLoad()
Notifies when the banner failed to load, containing a LoadError object describing the error and optionally a LoadResult object.
Action< ShowError > OnFailedToShow()
Notifies when the banner failed to show, containing a ShowError object describing the error.
Action OnShowed()
Notifies when the banner was shown. It can be called multiple times due to banner autorefreshing.
Action< ImpressionData > OnImpression()
Notifies when the banner impression was recorded, containing an ImpressionData object. It can be called multiple times due to banner autorefreshing.
Action OnClicked()
Notifies when the banner was clicked.
Action OnDismissed()
Notifies when the banner was dismissed.

Public Functions

Name
Banner Create(string placementId, Position position =Position.Bottom, Size size =Size.Phone, bool test =false, bool verbose =false)
Creates a new instance of a Banner.
Banner Create(string placementId, int x, int y, Size size, bool test =false, bool verbose =false)
Creates a new instance of a Banner.
int GetWidthFor(Size size)
Returns the width of the specified banner size.
int GetHeightFor(Size size)
Returns the height of the specified banner size.
void Load(CustomProperties customProperties =null)
Starts a new load call. After it loads successfully, it is automatically shown at the position specified when Create was called.
void SetPosition(int x, int y)
Sets a custom position for the banner.
void SetAdSpace(string adSpace)
Sets the ad space where the ad will be shown.
void Show()
Shows the banner at the last known position. It doesn't trigger a new load.
void Show(Position position)
Shows the banner at the indicated position. It doesn't trigger a new load.
void Dispose()
Disposes this banner object and can no longer be used for loading or showing.
void Hide()
Hides the banner.

Public Types Documentation

enum Position

Enumerator Value Description
Top 0
Bottom

Enum class representing the available positions where a banner can be placed.

enum Size

Enumerator Value Description
Phone 0
Tablet 1
MREC 2

Enum class representing the available sizes that a banner can be created with.

Public Events Documentation

event OnPrebiddingFinished

Action< PrebiddingResults > OnPrebiddingFinished()

Notifies when the prebidding call finished, containing a PrebiddingResults object.

event OnLoaded

Action< LoadResult > OnLoaded()

Notifies when the banner was loaded successfully, containing a LoadResult object. This callback can be called multiple times, due to the banner autorefresh triggering more loads.

event OnFailedToLoad

Action< LoadError, LoadResult > OnFailedToLoad()

Notifies when the banner failed to load, containing a LoadError object describing the error and optionally a LoadResult object.

event OnFailedToShow

Action< ShowError > OnFailedToShow()

Notifies when the banner failed to show, containing a ShowError object describing the error.

event OnShowed

Action OnShowed()

Notifies when the banner was shown. It can be called multiple times due to banner autorefreshing.

event OnImpression

Action< ImpressionData > OnImpression()

Notifies when the banner impression was recorded, containing an ImpressionData object. It can be called multiple times due to banner autorefreshing.

event OnClicked

Action OnClicked()

Notifies when the banner was clicked.

event OnDismissed

Action OnDismissed()

Notifies when the banner was dismissed.

Public Functions Documentation

function Create

static Banner Create(
    string placementId,
    Position position =Position.Bottom,
    Size size =Size.Phone,
    bool test =false,
    bool verbose =false
)

Creates a new instance of a Banner.

Parameters:

  • placementId A string containing a valid placement id.
  • position Position on the screen where the banner will appear after it has been loaded. See Position.
  • size Size of the banner. See Size for the available sizes.
  • test Whether a test banner should be loaded. This is only for testing purposes, should be false on production builds.
  • verbose Enable logging for this banner instance. This is only for debugging purposes, should be false on production builds.

Return: A Banner instance ready to load.

function Create

static Banner Create(
    string placementId,
    int x,
    int y,
    Size size,
    bool test =false,
    bool verbose =false
)

Creates a new instance of a Banner.

Parameters:

  • placementId A string containing a valid placement id.
  • x X Coordinate from top-left corner.
  • y Y Coordinate from top-left corner.
  • size Size of the banner. See Size for the available sizes.
  • test Whether a test banner should be loaded. This is only for testing purposes, should be false on production builds.
  • verbose Enable logging for this banner instance. This is only for debugging purposes, should be false on production builds.

Return: A Banner instance ready to load.

function GetWidthFor

static int GetWidthFor(
    Size size
)

Returns the width of the specified banner size.

Parameters:

  • size The banner size

Return:

function GetHeightFor

static int GetHeightFor(
    Size size
)

Returns the height of the specified banner size.

Parameters:

  • size The banner size

Return:

function Load

void Load(
    CustomProperties customProperties =null
)

Starts a new load call. After it loads successfully, it is automatically shown at the position specified when Create was called.

Parameters:

  • customProperties A CustomProperties object containing custom properties, useful for tracking.

function SetPosition

void SetPosition(
    int x,
    int y
)

Sets a custom position for the banner.

Parameters:

  • x X Coordinate from top-left corner
  • y Y Coordinate from top-left corner

function SetAdSpace

void SetAdSpace(
    string adSpace
)

Sets the ad space where the ad will be shown.

Parameters:

  • adSpace The space in your app from where the ad will be shown (eg: dashboard, settings). Used for tracking.

function Show

void Show()

Shows the banner at the last known position. It doesn't trigger a new load.

function Show

void Show(
    Position position
)

Shows the banner at the indicated position. It doesn't trigger a new load.

Parameters:

  • position The Position where the banner will be placed.

function Dispose

void Dispose()

Disposes this banner object and can no longer be used for loading or showing.

function Hide

void Hide()

Hides the banner.


Updated on 2024-11-07 at 18:31:49 +0000