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

Bug getting No placement configured for id :123456

Discussion in 'Unity Ads & User Acquisition' started by domdev, Jun 5, 2023.

  1. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    im getting error in device any idea? here is my ads code
    using ads 4.4.1 and unity 2022.3.0
    hope someone can help
    I already setup the placements in the dashboard
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Diagnostics;
    4. using UnityEngine;
    5. using UnityEngine.Advertisements;
    6. public class UnityAdManager : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
    7. {
    8.     public string gameIdAndroid = "2311143";
    9.     public string gameIdIOS = "";
    10.     public bool testMode = true;
    11.     string gameId = "";
    12.     string myPlacementIdReward = "rewardedVideo";
    13.     string myPlacementIdVideo = "video";
    14.     public bool isUnityVideo = false, isUnityIntertitial = false;
    15.     void Start()
    16.     {
    17.         isUnityVideo = false;
    18.         isUnityIntertitial = false;
    19.  
    20. #if UNITY_IOS
    21.         gameId = gameIdIOS ;
    22. #elif UNITY_ANDROID
    23.         gameId = gameIdAndroid;
    24. #endif
    25.  
    26.         //Advertisement.Load(gameId, true);
    27.         //Advertisement.Initialize(gameId, testMode);
    28.         if (!Advertisement.isInitialized && Advertisement.isSupported)
    29.         {
    30.             Advertisement.Initialize(gameId, testMode, this);
    31.         }
    32.     }
    33.  
    34.     public void OnInitializationComplete()
    35.     {
    36.         print("Unity Ads initialization complete.");
    37.         Advertisement.Load(gameId, this);
    38.     }
    39.  
    40.     public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    41.     {
    42.         print($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    43.     }
    44.  
    45.     public void OnUnityAdsAdLoaded(string adUnitId)
    46.     {
    47.         // If the ready Placement is rewarded, show the ad:
    48.         print("unity ads loadedd " + adUnitId);
    49.         if (adUnitId.Equals(myPlacementIdVideo))
    50.         {
    51.             print("unity ads loadedd "+ myPlacementIdVideo);
    52.             isUnityIntertitial = true;
    53.         }
    54.         else if (adUnitId.Equals(myPlacementIdReward))
    55.         {
    56.             print("unity ads loadedd " + myPlacementIdReward);
    57.             isUnityVideo = true;
    58.         }
    59.     }
    60.  
    61.     // Implement the Show Listener's OnUnityAdsShowComplete callback method to determine if the user gets a reward:
    62.     public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    63.     {
    64.         if (adUnitId.Equals(gameId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
    65.         {
    66.             gameObject.GetComponent<AdManager>().OnAdsWasClosed();
    67.             // Grant a reward.
    68.  
    69.             // Load another ad:
    70.             Advertisement.Load(gameId, this);
    71.         }
    72.     }
    73.  
    74.  
    75.     public void OnUnityAdsReady(string placementId)
    76.     {
    77.         // If the ready Placement is rewarded, show the ad:
    78.         if (placementId == myPlacementIdVideo)
    79.         {
    80.             isUnityIntertitial = true;
    81.         }
    82.         else if (placementId == myPlacementIdReward)
    83.         {
    84.             isUnityVideo = true;
    85.         }
    86.  
    87.     }
    88.  
    89.     public void OnShowUnityVideo()
    90.     {
    91.         Advertisement.Show(myPlacementIdReward);
    92.     }
    93.  
    94.     public void OnShowUnityIntertitial()
    95.     {
    96.         Advertisement.Show(myPlacementIdVideo);
    97.  
    98.     }
    99.  
    100.     // Implement Load and Show Listener error callbacks:
    101.     public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    102.     {
    103.         print($"Error loading Ad Unit: {adUnitId} - {error.ToString()} - {message}");
    104.         // Use the error details to determine whether to try to load another ad.
    105.     }
    106.  
    107.     public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    108.     {
    109.         print($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
    110.         // Use the error details to determine whether to try to load another ad.
    111.     }
    112.  
    113.     public void OnUnityAdsShowStart(string adUnitId) { }
    114.     public void OnUnityAdsShowClick(string adUnitId) { }
    115.  
    116. }
    117.  
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    597
    Looks like you didn't set the mediation partner for this project, please go to the monetization dashboard and set it on the settings page. After that, you should be able to see the correct placement IDs or Unit IDs. If you use the mediation partner, you should use placement IDs. If you only use Unity Ads SDK as exclusive, you should use Unit IDs.
    upload_2023-6-6_9-56-34.png
     
  3. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    okay thanks im gonna try
     
  4. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    oh I missed the Advertisement.Load(gameId, this); instead of placement id
     
  5. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    597
    Please use Advertisement.Load(Placement ID / Unit ID), game ID is only used for initialization.