Load
Rewarded Ads start loading automatically right after creation an instance:
string rewardedIdentifier = BidappBinding.Instance.CreateRewarded();
From creation function you will obtain an Rewarded Ad identifier that will be required to show and destroy ads, receive callbacks.
To check if Rewarded Ad is Ready to be displayed you may use next function:
BidappBinding.Instance.IsRewardedAdReady(rewardedIdentifier);
Show
To show an reward ad, call showRewarded
instance function:
BidappBinding.Instance.ShowRewarded(rewardedIdentifier);
Destroy with resource release
Call the following function to destroy a rewarded:
BidappBinding.Instance.DestroyRewarded(rewardedIdentifier);
DestroyRewarded
functions will also unregister all callback receiver instances, registered for the specified rewardedIdentifier
Callbacks / Delegates / Events
Register
To be able to register reward callbacks receiver you will need to inherit it from IBidappRewardedDelegate
public class BidappRewardedDelegate : IBidappRewardedDelegate
Then you need to register receiver of the callbacks for rewarded instance identifier:
BidappSDKDelegate.Instance.SetRewardedDelegate(
new BidappRewardedDelegate(),
rewardedIdentifier
);
Observe
You can observe ad loading events in callbacks:
public void OnRewardedDidLoadAd(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnRewardedDidLoadAd: rewardedId {identifier}, providerId: {networkId}");
}
public void OnRewardedDidFailToLoadAd(string identifier, string networkId, string errorDescription)
{
Debug.Log($"BIDUnity OnRewardedDidFailToLoadAd: rewardedId {identifier}, providerId: {networkId}, errorDescription: {errorDescription}");
}
Events related to displaying rewarded ad can be observed in callbacks:
public void OnRewardedDidDisplayAd(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnRewardedDidDisplayAd: rewardedId {identifier}, providerId: {networkId}");
}
public void OnRewardedDidClickAd(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnRewardedDidClickAd: rewardedId {identifier}, providerId: {networkId}");
}
public void OnRewardedDidHideAd(string identifier, string networkId)
{
Debug.Log($"BIDUnity OnRewardedDidHideAd: rewardedId {identifier}, providerId: {networkId}");
}
public void OnRewardedDidFailToDisplayAd(string identifier, string networkId, string errorDescription)
{
Debug.Log($"BIDUnity OnRewardedDidFailToDisplayAd: rewardedId {identifier}, providerId: {networkId}, errorDescription: {errorDescription}");
}
public void OnRewardedAllNetworksFailedToDisplayAd(string identifier)
{
Debug.Log($"BIDUnity OnRewardedAllNetworksFailedToDisplayAd: rewardedId {identifier}");
}
To be notified when user should be rewarded implement use callback:
public void OnUserDidReceiveReward(string identifier)
{
Debug.Log($"BIDUnity OnUserDidReceiveReward: rewardedId {identifier}");
}
Release
If you don't want to receive callbacks anymore you can unregister callback receiver instance:
BidappSDKDelegate.Instance.SetRewardedDelegate(
null,
rewardedIdentifier
);