Search Unity

Question Placement ID does not exist for gameId

Discussion in 'Unity Ads & User Acquisition' started by Bl00dyFish, Dec 28, 2023.

  1. Bl00dyFish

    Bl00dyFish

    Joined:
    Mar 12, 2022
    Posts:
    84
    Hello! I am trying to implement ads in my game, however, the ads fail every time.

    Here is the code I am using:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class Ads : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
    7. {
    8.     public string androidAdUnitId;
    9.  
    10.     string adUnitId;
    11.  
    12.     void Awake()
    13.     {
    14. #if UNITY_ANDROID
    15.         adUnitId = androidAdUnitId;
    16. #elif UNITY_EDITOR
    17.         adUnitId = androidAdUnitId;
    18. #endif
    19.     }
    20.  
    21.    public void LoadAd()
    22.     {
    23.         print("advertizemnt loading!");
    24.         Advertisement.Load(adUnitId, this);
    25.  
    26.  
    27.     }
    28.  
    29.     public void OnUnityAdsAdLoaded(string adUnitId)
    30.     {
    31.  
    32.        if (adUnitId.Equals(adUnitId))
    33.        {
    34.             print("advertizemnt loaded");
    35.             ShowAd();
    36.        }
    37.      
    38.  
    39.     }
    40.  
    41.     public void OnUnityAdsFailedToLoad(string placementId, UnityAdsLoadError error, string message)
    42.     {
    43.         print($"Error loading Ad Unit {adUnitId}: {error.ToString()}: - {message}");
    44.     }
    45.  
    46.     public void ShowAd()
    47.     {
    48.         Advertisement.Show(adUnitId, this);
    49.     }
    50.  
    51.  
    52.  
    53.  
    54.     public void OnUnityAdsShowStart(string adUnitId)
    55.     {
    56.     }
    57.     public void OnUnityAdsShowClick(string adUnitId)
    58.     {
    59.     }
    60.  
    61.  
    62.     public void OnUnityAdsShowComplete(string placementId, UnityAdsShowCompletionState showCompletionState)
    63.     {
    64.         // if (placementId.Equals(adUnitId) && showCompletionState.Equals(UnityAdsCompletionState.COMPLETED))
    65.         if (adUnitId.Equals(adUnitId) && showCompletionState.Equals(UnityAdsCompletionState.COMPLETED))
    66.      
    67.         {
    68.             print("advertizemnt showed");
    69.             PlayerPrefs.SetInt("Coins", PlayerPrefs.GetInt("Coins") + 500);
    70.         }
    71.     }
    72.  
    73.     public void OnUnityAdsShowFailure(string placementId, UnityAdsShowError error, string message)
    74.     {
    75.         print("failed to show");
    76.     }
    77.  
    78.  
    79. }
    80.  
    I am initializing the ads in another script, and that works fine.
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    The corresponding Placement ID or Unity ID under different Game IDs may be different. Please check whether the Unit ID/Placement ID you are using exists under the Game ID.