With the now.gg Rewarded Ads Module for Unity, you can implement in-app rewarded ads within your game on Unity.
To implement Rewarded ads:
The now.gg Rewarded Ads Unity module is included as a Unity package file (NowGGUnitySdk.unitypackage).
Add the module to your Unity project:
NowGGUnitySdk.unitypackage from your system.
Assets/Plugins/Android directory of your project using the Unity External Dependency Manager.The following sections illustrate the implementation of the now.gg Rewarded Ads functions which you can call from your app/game in Unity.
Once the now.gg Rewarded Ads Module has been imported, and the dependencies have been added; you can now integrate your app/game with now.gg Rewarded Ads module.
Before your app can show the ads, you must initialize the module.
Start by creating a class that contains the now.gg Rewarded Ads implementation and attach it to a game object that you can use to initialize the module, as illustrated below:
void Start()
{
NowGGAdsManager.Instance.OnInitSuccess += OnInitSuccess;
NowGGAdsManager.Instance.OnInitFailed += OnInitFailed;
NowGGAdsManager.Instance.OnNowGGRewardedAdDismissed += OnAdDismissed;
NowGGAdsManager.Instance.OnNowGGRewardedAdFailedToLoad += OnAdFailedToLoad;
NowGGAdsManager.Instance.OnNowGGRewardedAdShownToUser += OnAdShownToUser;
NowGGAdsManager.Instance.OnUserEarnedReward += OnUserEarnedReward;
NowGGAdsManager.Instance.Initialize();
}
Note:
Initialize() function of the NowGGAdsManager class is called to initialize the Rewarded Ads.Once the module has been successfully initialized, you can show the in-app rewarded ads.
Based on your requirements, you can display rewarded ads in your app by calling the NowGGAdsManager.Instance.ShowRewardedAd() function.
now.gg Rewarded Ads utilizes the following callback functions to inform your app about the status of the rewarded ad request:
void OnAdShownToUser(); – The Ad is displayed on the user’s screen.void OnAdFailedToLoad(String error); – The Ad failed to load.void OnAdDismissed(bool rewardEarned); – The Ad was dismissed. Continue with app operations.
rewardEarned will be False.rewardEarned will be True.void OnUserEarnedReward(); The user earned a reward.The following code segment illustrates the above-listed callback functions and their implementation:
public class RewardsSDKDemo : MonoBehaviour
{
// Show Ad
public void ShowAd()
{
NowGGAdsManager.Instance.ShowRewardedAd();
}
// Initialize Success
private void OnInitSuccess()
{
Debug.Log("OnInitSuccess");
}
// Initialize Failed
private void OnInitFailed(string error)
{
Debug.Log("OnInitFailed.. " + error);
}
// Ad is displayed on the User's screen
private void OnAdShownToUser()
{
Debug.Log("OnAdShownToUser");
}
// Ad failed to load
private void OnAdFailedToLoad(string error)
{
Debug.Log("OnAdFailedToLoad.." + error);
}
//Ad was dismissed by the user; continue with app operations.
private void OnAdDismissed(bool rewardEarned)
{
Debug.Log("OnAdDismissed.." + rewardEarned);
}
//User earned a reward
private void OnUserEarnedReward()
{
Debug.Log("OnUserEarnedReward");
}
}
Rewarded Ads Module
Rewarded Ads Module
Document Rev. 1.0