Banner
Here you can find our demo implementation of banner ads in Bidon.
Create An Instance
Add Bidon namespace to your script.
using Bidon.Mediation;
Create a BidonBannerAd
instance as shown below.
var bidonBanner = new BidonBannerAd();
Subscribe To Events
Subscribe to desired events for receiving callbacks during ad object lifecycle.
bidonBanner.OnAdLoaded += (sender, args) =>
{
Debug.Log($"Ecpm: {args.Ad?.Ecpm}");
};
Below you can find all available events for banners.
event EventHandler<BidonAdLoadedEventArgs> OnAdLoaded;
event EventHandler<BidonAdLoadFailedEventArgs> OnAdLoadFailed;
event EventHandler<BidonAdShownEventArgs> OnAdShown;
event EventHandler<BidonAdShowFailedEventArgs> OnAdShowFailed;
event EventHandler<BidonAdClickedEventArgs> OnAdClicked;
event EventHandler<BidonAdExpiredEventArgs> OnAdExpired;
event EventHandler<BidonAdRevenueReceivedEventArgs> OnAdRevenueReceived;
Set Format
We recommend setting format before trying to load an ad.
_bannerAd.SetFormat(BidonBannerFormat.Mrec);
Default format is Banner
Here you can find all supported banner formats.
Banner Format | Size | Description |
---|---|---|
Banner | 320 x 50 | Fixed size banner for phones |
Leaderboard | 728 x 90 | Fixed size banner for pads |
Mrec | 300 x 250 | Fixed medium rectangle banners |
Adaptive | -/- x 50/90 | Flexible width banners |
Set Position
Set desired banner position and rotation using one of the following methods
Only the last method called will have an effect
Predefined Position
bidonBanner.SetPredefinedPosition(BidonBannerPosition.HorizontalBottom);
Position | Description |
---|---|
HorizontalBottom | This position places the banner at the bottom of the screen, typically spanning horizontally |
HorizontalTop | This position places the banner at the top of the screen, typically spanning horizontally |
VerticalLeft | This position places the banner on the left side of the screen, typically spanning vertically |
VerticalRight | This position places the banner on the right side of the screen, typically spanning vertically |
Custom Position And Rotation
var offset = new Vector2Int(Screen.width / 2, Screen.height / 6);
int angle = -8;
var anchorPoint = new Vector2(0.5f, 0f);
bidonBanner.SetCustomPositionAndRotation(offset, angle, anchorPoint);
AnchorPoint
affects rotation and positioning (x, y: 0 to 1)
Angle
is in degrees (-180 to 180)
Load
double priceFloor = 0.01d;
bidonBanner.Load(priceFloor);
Show
if (bidonBanner.IsReady())
{
bidonBanner.Show();
}
Hide
if (bidonBanner.IsShowing())
{
bidonBanner.Hide();
}
Dispose
To release resources we recommend destroying instances when you don't need them anymore.
bidonBanner.Dispose();
bidonBanner = null;
Send Extra Data
The value has to be one of the following types: bool
, char
, int
, long
, float
, double
, string
.
Passing null
as a value will remove existing KeyValuePair
from dictionary.
bidonBanner.SetExtraData("some_key", true);
You can also read all current extras as shown below:
var extras = bidonBanner.GetExtraData();
Win / Loss Notifications
Use the following methods to let Bidon know whether or not it won the show opportunity.
bidonBanner.NotifyWin();
bidonBanner.NotifyLoss("winner_demand_id", (double)winnerEcpm);