Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question MobileAds.Initialize(string)' is obsolete

Discussion in 'Scripting' started by gamer123454321, Sep 22, 2020.

  1. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Hi! I'm trying to put Admob ads in my game. I watched couple tutorials they all write different. So hard to follow and they are not really update I guess. There are couple errors. now I'm trying to fix this one first.


    Code (CSharp):
    1.  private BannerView bannerView;
    2.     private RewardBasedVideoAd rewardedAd2;
    3.  
    4.     private string idApp, idBanner, idVideoAds;
    5.     void Start()
    6.     {
    7.        
    8.         rewardedAd2 = RewardBasedVideoAd.Instance;
    9.          idApp = " ";
    10.        
    11.      
    12.         // Initialize the Google Mobile Ads SDK.
    13.         MobileAds.Initialize(idApp);
    14.         this.RequestBanner();
    15.         HandleBannerAdEvent();


    The error message is:
    MobileAds.Initialize(string)' is obsolete: 'Initialize(string appId) is deprecated, use Initialize(Action<InitializationStatus> initCompleteAction) instead
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
    Have you tried switching to the form of Initialize that takes an action parameter instead, as suggested by the error message?
     
  3. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Don't really how to apply use Initialize(Action<InitializationStatus> initCompleteAction) this code into my code
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
  5. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Like this? There no need to put my App id?

    Code (CSharp):
    1.   private BannerView bannerView;
    2.     private RewardBasedVideoAd rewardedAd2;
    3.  
    4.     private string idApp, idBanner, idVideoAds;
    5.     void Start()
    6.     {  
    7.         rewardedAd2 = RewardBasedVideoAd.Instance;
    8.  
    9.         // Initialize the Google Mobile Ads SDK.
    10.         MobileAds.Initialize(initStatus => {});
    11.  
    12.         this.RequestBanner();
    13.         HandleBannerAdEvent();
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
    florinel2102 likes this.
  7. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Okay! Thank you
     
  8. Dudusstar

    Dudusstar

    Joined:
    Nov 19, 2020
    Posts:
    59
    Hey" I'm having the same issue. Did you finally find a solution? A banner an interstitial are working but not the rewarded. An I get the same error message in microsoft visual studio console. Thanks!
     
  9. Arc_gae

    Arc_gae

    Joined:
    Jun 1, 2022
    Posts:
    1
    what should we put in the bracket?
    1. MobileAds.Initialize(initStatus => { });