MobileAds.Initialize(string)' is obsolete

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.

 private BannerView bannerView;
    private RewardBasedVideoAd rewardedAd2;

    private string idApp, idBanner, idVideoAds;
    void Start()
    {
       
        rewardedAd2 = RewardBasedVideoAd.Instance;
         idApp = " ";
       
      
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(idApp);
        this.RequestBanner();
        HandleBannerAdEvent();

The error message is:
MobileAds.Initialize(string)’ is obsolete: 'Initialize(string appId) is deprecated, use Initialize(Action initCompleteAction) instead

Have you tried switching to the form of Initialize that takes an action parameter instead, as suggested by the error message?

Don’t really how to apply use Initialize(Action initCompleteAction) this code into my code

Like this? There no need to put my App id?

  private BannerView bannerView;
    private RewardBasedVideoAd rewardedAd2;

    private string idApp, idBanner, idVideoAds;
    void Start()
    {   
        rewardedAd2 = RewardBasedVideoAd.Instance;

        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(initStatus => {});

        this.RequestBanner();
        HandleBannerAdEvent();

You set your App Id in the Unity Editor:

I suggest reading through that whole quick-start page.

1 Like

Okay! Thank you

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!

what should we put in the bracket?

  • MobileAds.Initialize(initStatus => { });