Search Unity

Unity Ads doesn't work on the device

Discussion in 'Unity Ads & User Acquisition' started by LuksProject, Apr 14, 2020.

  1. LuksProject

    LuksProject

    Joined:
    Apr 14, 2020
    Posts:
    3
    I am using the unity Monetization SDK to monetize my game. The videos and banner work in the Editor but when testing on the Device it doesn't work, I already checked if the connection with the project in the dashborad is correct, the IDs are all correct, but I don't know why it doesn't work

    My code:

    The IDs are not XXXXXXX, of course.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5. public class AdsController : MonoBehaviour, IUnityAdsListener
    6. {
    7. #if UNITY_IOS
    8.      private string gameId = "XXXXXXX";
    9. #elif UNITY_ANDROID
    10.      private string gameId = "XXXXXXX";
    11. #endif
    12.      string rewardedPlacement = "rewardedVideo";
    13.      string videoPlacement = "video";
    14.      string bannerPlacement = "banner";
    15.      public GameController gameController;
    16.      public Swipe swipeController;
    17.      public UIAnimation uiAnimation;
    18.      // Start is called before the first frame update
    19.      void Start()
    20.      {
    21.          Advertisement.AddListener(this);
    22.          Advertisement.Initialize(gameId, true);  
    23.      }
    24.      public void ShowVideoAds()
    25.      {
    26.          Advertisement.Show(videoPlacement);
    27.      }
    28.      public void ShowRewardedAds(string p)
    29.      {
    30.          Advertisement.Show(p);
    31.      }
    32.      public void ShowBanner()
    33.      {
    34.          Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
    35.          Advertisement.Banner.Show(bannerPlacement);
    36.      }
    37.      public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    38.      {
    39.          if(showResult == ShowResult.Finished)
    40.          {
    41.           //Rewarded
    42.          }
    43.          else if (showResult == ShowResult.Skipped)
    44.          {
    45.              // Do not reward the user for skipping the ad.
    46.          }
    47.          else if (showResult == ShowResult.Failed)
    48.          {
    49.              Debug.LogWarning("The ad did not finish due to an error");
    50.              }
    51.       }
    52. }
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Please check the device log to determine whether the Ad is not filled.
     
  3. LuksProject

    LuksProject

    Joined:
    Apr 14, 2020
    Posts:
    3
    I was able to solve the problem by downloading the unity Ads 3.4.2. Version 3.4.4 has an error in saying that unity ads are duplicated.
    You should fix this error in the next version.