Help with ads

I am a little confused about the implementation of rewarded ads. I am trying to use

“public void OnUnityAdsDidFinish (string placementId, ShowResult showResult)”

by following the guide Unity developer integration guides.

I am confused about the second parameter showResult. how can I go about calling rewarded video ad and checking if it was fully watched and do something after its finished? when calling this function during a specific event like button click, what do I need to write as the second parameter? where do I get ShowResult?

one more thing. If I understand correctly when I decide to list my app on google store, I need to link unitys privacy policy in the privacy policy section? Or I need my own privacy policy for the game and I need to have the link in my own privacy policy?

Hi,

OnUnityAdsDidFinish() is a callback/eventhandler method, i.e. being called by Ads SDK. So inside the method, you can use showResult argument/value to see if user skipped or watched video to end.

Regarding privacy policy, likely best if you can create your own, so users doesn’t get confused. And then you can link to Unity from your privacy policy.

/Rasmus

Thanks for the reply Rasmus, maybe i explained it wrong. So what i want to know is how do i call the function in the first place. I need to put 2nd parameter to be able to call the function so where do i get that second parameter? I saw few examples where they did

var options = new ShopOptions();
and use options.showResult as that second parameter but thats obviously wrong

This is the full rewarded video example from the documentation.

In this example, you do not ever call OnUnityAdsDidFinish manually. As Rasums said, that is handled by the Ads SDK. You are only responsible for two things:

  1. Assigning the IUnityAdsListener instance to the Advertisement system. (Done in the Start method.)
  2. Calling Advertisement.Show (Done in OnUnityAdsReady, which I would not recommend.)

After you call Advertisement.Show, if you have the IUnityAdsListener set up, then the OnUnityAdsDidFinish will be called by the Ads SDK as expected and you can get the ShowResult.

using UnityEngine;
using UnityEngine.Advertisements;

public class RewardedAdsScript : MonoBehaviour, IUnityAdsListener {

    string gameId = "1234567";
    myPlacementId = “rewardedVideo”;
    bool testMode = true;

    // Initialize the Ads listener and service:
    void Start () {
        Advertisement.AddListener (this);
        Advertisement.Initialize (gameId, testMode);
    }

    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish (string placementId, ShowResult showResult) {
        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished) {
            // Reward the user for watching the ad to completion.
        } else if (showResult == ShowResult.Skipped) {
            // Do not reward the user for skipping the ad.
        } else if (showResult == ShowResult.Failed) {
            Debug.LogWarning (“The ad did not finish due to an error.);
        }
    }

    public void OnUnityAdsReady (string placementId) {
        // If the ready Placement is rewarded, show the ad:
        if (placementId == myPlacementId) {
            Advertisement.Show (myPlacementId);
        }
    }

    public void OnUnityAdsDidError (string message) {
        // Log the error.
    }

    public void OnUnityAdsDidStart (string placementId) {
        // Optional actions to take when the end-users triggers an ad.
    }
}
1 Like