Load and Show
Banner Ads start loading automatically right after creation an instance.
Use the following code to create and show banners 320x50 banner:
string bannerIdentifier = BidappBinding.Instance.ShowBannerAtPosition(
BidappBannerPosition.BottomCenter,
BidappBannerSize.Size_320x50
);
or, alternatively -
string bannerIdentifier = BidappBinding.Instance.ShowBanner(
BidappBannerSize.Size_320x50,
0f, 100f, 320f, 50f
);
To show the 300x250 banner you should use the following code:
string bannerIdentifier = BidappBinding.Instance.ShowBannerAtPosition(
BidappBannerPosition.BottomCenter,
BidappBannerSize.Size_300x250
);
or, alternatively -
string bannerIdentifier = BidappBinding.Instance.ShowBanner(
BidappBannerSize.Size_300x250,
0f, 100f, 320f, 50f
);
Refresh
To manually refresh an ad on banner you should call the refreshBanner function:
BidappBinding.Instance.RefreshBanner(bannerIdentifier);
Alternatively, a banner can refresh itself automatically by timer.
To start banner autorefresh you should use the following code:
float newRefreshInterval = 30f // 30 seconds
BidappBinding.Instance.SetBannerRefreshInterval(bannerIdentifier, newRefreshInterval);
You can also stop autorefresh when it is no longer needed:
BidappBinding.Instance.StopAutorefresh()
Destroy with resource release
If you need to destroy the banner and free resources, you should use the following method:
BidappBinding.Instance.RemoveBanner(bannerIdentifier);
RemoveBanner
functions will also unregister all callback receiver instances, registered for the specified bannerIdentifier
Callbacks / Delegates / Events
Register
To be able to register banner callbacks receiver you will need to inherit it from IBidappBannerDelegate
public class BidappBannerDelegate : IBidappBannerDelegate
Then you need to register receiver of the callbacks for banner instance identifier:
BidappSDKDelegate.Instance.SetBannerDelegate(
new BidappBannerDelegate(),
bannerIdentifier
);
Observe
You can observe banner events by specifying the delegate:
public void OnBannerDidDisplayAd(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnBannerDidDisplayAd: bannerId {identifier}, providerId: {networkId}");
}
public void OnBannerFailedToDisplayAd(string identifier, string networkId, string errorDescription)
{
Debug.Log($"BIDUnity OnBannerFailedToDisplayAd: bannerId {identifier}, providerId: {networkId}, errorDescription: {errorDescription}");
}
public void OnBannerAllNetworksFailedToDisplayAd(string identifier)
{
Debug.Log($"BIDUnity OnBannerAllNetworksFailedToDisplayAd: bannerId {identifier}");
}
public void OnBannerClicked(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnBannerClicked: bannerId {identifier}, providerId: {networkId}");
}
Release
If you don't want to receive callbacks anymore you can unregister callback receiver instance:
BidappSDKDelegate.Instance.SetBannerDelegate(
null,
bannerIdentifier
);