-
Notifications
You must be signed in to change notification settings - Fork 0
Unity Plugin Rewarded Integration
The RewardedNative should be created inside a script which is linked to a GameObject. It must be created using the HyBidRewardedAdFactory createRewardedAd() method which creates a rewarded ad based on the platform that the application is being built for.
public static HyBidRewardedAd createRewardedAd(MonoBehaviour parent) A sample of this instantiation is the following:
HyBidRewardedAd rewarded = HyBidRewardedAdFactory.createRewardedAd(this); In the previous sample this is an object which inherits from MonoBehaviour so it’s linked to a GameObject.
After creating the Rewarded Ad you must set the appToken and placement properties:
rewarded.appToken = “App Token obtained from PubNative dashboard”;
rewarded.placement = “Placement Name configured and obtained from the PubNative Dashboard”; Setting the listener is also recommended to check the correct behaviour of the ads. You should implement the IRewardedListener for HyBidRewardedAd.
public interface IRewardedListener
{
void OnRewardedLoaded ();
void OnRewardedLoadFailed (Exception error);
void OnRewardedClick ();
void OnRewardedOpened ();
void OnRewardedClosed ();
void onReward ();
}Adding a RewardedListener to the ** HyBidRewardedAd** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed.
Here’s an implementation sample:
rewarded.RewardedListener = REWARDED_LISTENER_INSTANCE;To load the rewarded ad you should use the Load() method. This method must be invoked in the following way:
rewarded.Load(); The result of this method will be received in the ** RewardedListener** callbacks.
After the ad is loaded successfully, the method Show() must be used to display the ad.
Here’s is the sample of how to show rewarded ad on screen.
rewarded.Show(); Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.
Here is a complete code sample about how you can integrate the Rewarded Ad.
iOS Integration
Android Integration
Displaying ads in Unity