Rewarded Ads for Unity

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:

  1. Download and Import the now.gg Rewarded Ads Unity module.
  2. Add required dependencies.
  3. Implement now.gg Rewarded Ads to your project.

Download and Import the Module

The now.gg Rewarded Ads Unity module is included as a Unity package file (nowgg-rewarded-ads.unitypackage).

Add the module to your Unity project:

  1. Download the package containing the latest version of now.gg Rewarded Ads Module for Unity.
  2. After you have downloaded the module, import it to your project.
    To do this:

    • Click on Assets > Import Package > Custom Package, as shown below:
    • Select nowgg-rewarded-ads.unitypackage that you previously downloaded.
    • Select all the listed files and click on Import.

Once all the module files have been imported, a folder named ‘NowGGSdk‘ will be added to your project. You can find this folder at the root of the Assets folder.

Note: Please do not modify the NowGGSdk folder, as that contains all the assets related to now.gg Rewarded Ads.

Add Required Dependencies

This operation will download and add all the required dependencies to the Assets/Plugins/Android directory of your project using the Unity External Dependency Manager.

To add the required dependencies:

  • Click on Assets > External Dependency Manager > Android Resolver > Resolve.

Implement now.gg Rewarded Ads

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.

1. Initialize the 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:

  • You should initialize the SDK module only once, ideally at app launch.
  • Initialize() function of the NowGGAdsManager class is called to initialize the Rewarded Ads.
  • The module responses are recorded using the callback functions, as illustrated above.

2. Show 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.
    • If the Ad was prematurely dismissed by the user, rewardEarned will be False.
    • If the Ad completes its required run time to earn the reward, rewardEarned will be True.
  • void OnUserEarnedReward(); The user earned a reward.

Note:

  • Callback functions are not invoked on the main thread. Please ensure that all UI operations are carried out from the main thread.

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");
      }
}

Important Information

×

Document Rev. 1.0

Text copied to clipboard
Link copied to clipbord
Questions? Please reach out to us at dev-support@now.gg