Search Unity

How to check if the player watched the rewarded ad?

Discussion in 'Unity Ads & User Acquisition' started by TortoRacoon, Jul 18, 2019.

Thread Status:
Not open for further replies.
  1. TortoRacoon

    TortoRacoon

    Joined:
    Apr 17, 2019
    Posts:
    61
    I tried the implementation guide, I do not know if its outdated but It does not work to me, I saw tutorials that had different methods (there seem to be many) but none worked for me.

    How in the world can I check if the player watched the video so I give them the reward!!!
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @eriuop

    There are a couple different ways, but I would recommend the way described in this example:
    https://unityads.unity3d.com/help/unity/integration-guide-unity#rewarded-video-ads

    You have to make sure:
    1. You implement IUnityAdsListener
    2. You add the listener to the Ad system to get the callbacks

    The part where the reward actually happens is in OnUnityAdsDidFinish:

    Code (CSharp):
    1. string rewardedPlacement = "rewardedVideo";
    2. // Implement IUnityAdsListener interface methods:
    3. public void OnUnityAdsDidFinish (string placementId, ShowResult showResult)
    4. {
    5.     //Make sure this callback is for the correct placement
    6.     if(placementId.Equals(rewardedPlacement))
    7.     {
    8.         // Define conditional logic for each ad completion status:
    9.         if (showResult == ShowResult.Finished) {
    10.             // Reward the user for watching the ad to completion.
    11.         } else if (showResult == ShowResult.Skipped) {
    12.             // Do not reward the user for skipping the ad.
    13.         } else if (showResult == ShowResult.Failed) {
    14.             Debug.LogWarning (“The ad did not finish due to an error.);
    15.         }
    16.     }
    17. }
    Note that this callback will be sent for every placement, so make sure you are checking for the correct ones.
     
Thread Status:
Not open for further replies.