filipst
filipst

Reputation: 1573

Windows phone 8 AdMob ReceiveAd not working

I have made unity application, and I have exported it to visual studio so I can add Google AdMob. I just want to show interstitial ad when ad loads. I am using latest Google.dll file ver:6.5.13.0. Here is my code:

        //Google AdMob begin
        private InterstitialAd interstitialAd;
        AdRequest adRequest;
        Boolean interstitialApploaded = false;
        int test = 0;
        //Google AdMob end

        // Constructor
        public MainPage()
        {
            var bridge = new UnityBridge();
            UnityApp.SetBridge(bridge);
            InitializeComponent();
            bridge.Control = DrawingSurfaceBackground;

            interstitialAd = new InterstitialAd("my interstitial ID");
            interstitialAd.ReceivedAd += OnAdReceived;
            interstitialAd.FailedToReceiveAd += OnFailedToReceiveAd;
            interstitialAd.DismissingOverlay += OnDismissingOverlay;

            adRequest = new AdRequest();
            adRequest.ForceTesting = true;
            interstitialAd.LoadAd(adRequest);
        }

        //Google AdMob BEGIN
        private void OnDismissingOverlay(object sender, AdEventArgs e)
        {
            Debug.WriteLine("Ad dismissed.");
            interstitialAd.LoadAd(adRequest);
        }

        private void OnFailedToReceiveAd(object sender, AdErrorEventArgs e)
        {
            Debug.WriteLine("Ad failed to load!!!!");
            interstitialApploaded = false;
            test = 1;
        }

        private void OnAdReceived(object sender, AdEventArgs e)
        {
            Debug.WriteLine("Ad loaded. Have fun!");
            interstitialApploaded = true;
            test = 2;
            interstitialAd.ShowAd();
        }

Now, the problem is that I am not getting any of the Debug.Writeline messages. So I guess ReceiveAd is not working. Any thoughts? Thank you.

Upvotes: 2

Views: 568

Answers (2)

Khaled Jemni
Khaled Jemni

Reputation: 1

You have to add the advertise through Unity with its advertisers there will be always an exception if you try to change the exported .sln file from Unity

Upvotes: 0

Amit Bhatiya
Amit Bhatiya

Reputation: 2621

Your code seems to be Right, check your internet connection and Capabilities that are needed for Ad-loading and try after removing adRequest.ForceTesting = true; that is for test Ad Interstitial.

Upvotes: 1

Related Questions