Search Unity

Urgent ! How to use unity ads in unity 2017.4.40f1

Discussion in 'Unity Ads & User Acquisition' started by adarshdesai, Sep 9, 2021.

  1. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    Unity ads in unity 2017.4.40f1 , hello guys I am newbie please help me out.
    There is no package manager , to import the package. There are soo many toturials using many ways .i don't know which way . please help me out
     
  2. Unity_Jae

    Unity_Jae

    Unity Technologies

    Joined:
    Aug 30, 2021
    Posts:
    50
    Hello, adarshdesai

    Sorry to hear that you are having trouble implementing Unity Ads.
    In Unity2017.4.40f1 you can use Unity Ads by turning on the Ads menu in the Services window.




    Hope this helps. If you have any other questions please leave a comment.
    Have a good day!

    p.s: I understand you have a reason for using Unity2017.4.40f1, but I kindly recommend using the latest LTS version of Unity. :)
     
  3. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    Hey thanks bro , but where is the sdk
     
  4. Unity_Jae

    Unity_Jae

    Unity Technologies

    Joined:
    Aug 30, 2021
    Posts:
    50
    Since you have turned on the Ads in Services, you already have the SDK, still able to use it.
    However, the Advertisement SDK version is 2.0 in Unity2017.4 and the API is quite different from the latest version which is 3.7.5
    Here is an example code of how to use Unity ads in Unity2017.4.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3.  
    4. public class InterstitialAdExample : MonoBehaviour
    5. {
    6.     [SerializeField] string _androidAdUnitId = "Interstitial_Android";
    7.     [SerializeField] string _iOsAdUnitId = "Interstitial_iOS";
    8.     string _adUnitId;
    9.     string gameId = "yourGameId";
    10.     bool testMode = true;
    11.  
    12.     void Awake()
    13.     {
    14.         Advertisement.Initialize(gameId, testMode);
    15.         // Get the Ad Unit ID for the current platform:
    16.         _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer)
    17.             ? _iOsAdUnitId
    18.             : _androidAdUnitId;
    19.     }
    20.  
    21.     // Show the loaded content in the Ad Unit:
    22.     public void ShowAd()
    23.     {
    24.         // Note that if the ad content wasn't previously loaded, this method will fail
    25.         Debug.Log("Showing Ad: " + _adUnitId);
    26.         Advertisement.Show(_adUnitId);
    27.     }
    28. }
    If you copy-paste this code, change gameId, and trigger `ShowAd()`, you will see the test ads as below.



    You might want to check how other people implemented Unity Ads in Unity2017.

    Hope this helps. And again, I kindly recommend using the latest LTS version of Unity.
    Have a good day!
     
  5. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    Thank you man
     
    Unity_Jae likes this.
  6. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    IT IS WORKING THANKS A LOT
     
    Unity_Jae likes this.
  7. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Hey guys, does the Unity cookies dialog appears the first time you watch an Ad? It happens here and it messes with the callback, im getting OnUnityAdsShowFailure callback in my rewarded ads every time this dialog appears.

    Any hint ? Thanks
     
  8. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    No bro , not for me
     
  9. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    So what happens to you? you dont get the unity cookies dialog? or your callback simply doesn't fail if this dialog appears?
    Thanks for your answer.
     
  10. adarshdesai

    adarshdesai

    Joined:
    Apr 14, 2021
    Posts:
    35
    No I don't get it , I have also implemented callbacks. So you just try showing your ads , and don't implement callback and then try maybe
     
  11. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    But you need the callback for the rewarded ads, otherwise you can't know if the player has seen the ad or not for sure.