I am a newbie at Unity. I am making a phone game on Unity. My games work on real device and I can compile it perfectly. But When I add the Admob sdk that named: GoogleMobileAds-v8.1.0 to my project. (Also, I do not know which version is the latest) It is not working. Also, I searched on too many forums. It seems like version issues. But I do not know how to fix it? My project is so simple. Just I want to show the ad on my phone. Here is the code. (I have used to plugin on that https://developers.google.com/admob/unity/quick-start?hl=en )
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class admob_test : MonoBehaviour
{
public Text bilgi;
BannerView _bannerView;
void Start()
{
MobileAds.Initialize(initStatus => { });
CreateBannerView();
}
#if UNITY_ANDROID
private string _adUnitId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
private string _adUnitId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
#else
private string _adUnitId = "unused";
#endif
public void CreateBannerView()
{
Debug.Log("Creating banner view");
// If we already have a banner, destroy the old one.
if (_bannerView != null)
{
DestroyAd();
}
// Create a 320x50 banner at top of the screen
_bannerView = new BannerView(_adUnitId, AdSize.Banner, AdPosition.Top);
}
public void LoadAd()
{
// create an instance of a banner view first.
if (_bannerView == null)
{
CreateBannerView();
}
// create our request used to load the ad.
AdRequest adRequest = new AdRequest.Builder().Build();
adRequest.Keywords.Add("unity-admob-sample");
// send the request to load the ad.
Debug.Log("Loading banner ad.");
_bannerView.LoadAd(adRequest);
}
public void DestroyAd()
{
if (_bannerView != null)
{
Debug.Log("Destroying banner ad.");
_bannerView.Destroy();
_bannerView = null;
}
}
// Update is called once per frame
public void BannerButton() {
_bannerView.Destroy();
}
public void InterstatialButton() { }
public void rewardedbutton() { }
}
And here are the warning messages:
You can see it in second image.APİ is deprecated. How can I fix it?