Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Reward Ads show, but do not reward player

Discussion in 'Unity Ads & User Acquisition' started by WyrmCS, Mar 1, 2019.

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

    WyrmCS

    Joined:
    Nov 9, 2014
    Posts:
    24
    I've been trying to setup rewards for my players by watching an ad and getting x amount of coins.

    It works fine in the editor, but when I test it on the device, the test ad shows but does not reward even though the test ad was already shown.

    Anyone know how to fix this?

    Here's my code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.Monetization;
    6.  
    7. [RequireComponent(typeof(Button))]
    8. public class RewardedAd : MonoBehaviour
    9. {
    10.     public string rewardID = "rewardedVideo";
    11.     private Button adButton;
    12.     public bool testMode = true;
    13.  
    14.     public GameObject rewardGUI;
    15.     public GameObject skippedGUI;
    16.  
    17. #if UNITY_IOS
    18.     private string gameID = "";
    19. #elif UNITY_ANDROID
    20.     private string gameID = "*******";
    21. #endif
    22.  
    23.     private void Start()
    24.     {
    25.         adButton = GameObject.Find("WatchAd").GetComponent<Button>();
    26.         if (adButton)
    27.         {
    28.             adButton.onClick.AddListener(ShowAd);
    29.         }
    30.  
    31.         if (Monetization.isSupported)
    32.         {
    33.             Monetization.Initialize(gameID, testMode);
    34.         }
    35.     }
    36.  
    37.     private void Update()
    38.     {
    39.         if (adButton)
    40.         {
    41.             adButton.interactable = Monetization.IsReady(rewardID);
    42.         }
    43.     }
    44.  
    45.     public void ShowAd()
    46.     {
    47.         ShowAdCallbacks options = new ShowAdCallbacks();
    48.         options.finishCallback = HandleShowResult;
    49.         ShowAdPlacementContent ad = Monetization.GetPlacementContent(rewardID) as ShowAdPlacementContent;
    50.         ad.Show(options);
    51.     }
    52.  
    53.     void HandleShowResult(ShowResult result)
    54.     {
    55.         if(result == ShowResult.Finished)
    56.         {
    57.             DataManager dataManager = GameObject.Find("DataManager").GetComponent<DataManager>();
    58.             dataManager.coinAmount = dataManager.coinAmount + 500;
    59.             PlayerPrefs.SetInt("CoinAmount", dataManager.coinAmount);
    60.             StartCoroutine(WaitToEndGUI());
    61.         } else if (result == ShowResult.Skipped)
    62.         {
    63.             StartCoroutine(WaitToEndSkipGUI());
    64.         }
    65.     }
    66.  
    67.  
    68.  
    69.     IEnumerator WaitToEndGUI()
    70.     {
    71.         if (!rewardGUI.gameObject.activeInHierarchy)
    72.         {
    73.             rewardGUI.gameObject.SetActive(true);
    74.         }
    75.  
    76.         yield return new WaitForSeconds(3);
    77.         rewardGUI.gameObject.SetActive(false);
    78.     }
    79.  
    80.     IEnumerator WaitToEndSkipGUI()
    81.     {
    82.         if (!skippedGUI.gameObject.activeInHierarchy)
    83.         {
    84.             skippedGUI.gameObject.SetActive(true);
    85.         }
    86.         yield return new WaitForSeconds(3);
    87.         skippedGUI.gameObject.SetActive(false);
    88.     }
    89. }
    90.  
     
  2. HikmetDuran

    HikmetDuran

    Joined:
    May 7, 2017
    Posts:
    11
    Same issue here, i have tried lots of things but not solved.
    ***Most interesting thing for me is: Some ads give reward, some ads don't.
    In editor, all of rewards are working.

    I tried:
    -Disabling unity ads on services and importing from Asset Store
    -Using every version on package manager
    -Initializing from code

    *Semi-worked for me:
    I used to have a single AdManager script and give rewards in it with:
    Code (CSharp):
    1. if(RewardReason == otherGameObject)
    2. {
    3.       otherGameObject.GiveReward();
    4. }
    Then i seperated every script and show ads and give reward for each reward type. Its messy but it worked on iOS, but not on Android.

    And i have to publish this game on this weekend!
     
  3. sourabhpramod

    sourabhpramod

    Joined:
    May 2, 2020
    Posts:
    1
    Yes same here. some ads give rewards some dont! if you solved the issue please share...PLEASE!
     
  4. SpaceJunkie

    SpaceJunkie

    Joined:
    Mar 9, 2019
    Posts:
    1
    I'm the same. Some ads work and some don't. They always work in editor. Very strange. Please share if you have solved it. Thanks.
     
  5. asukakhadkaiwa

    asukakhadkaiwa

    Joined:
    Feb 9, 2019
    Posts:
    3
    Same problem. Did anybody found the fix for this issue ?
     
  6. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
Thread Status:
Not open for further replies.