Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by VasilijLatushko · Aug 15, 2015 at 05:11 PM · androidiosadmob

Admob on iOS and Android. Interstitial ads are showing but events are not firing.

When I tested demo scene from the admob plugin for unity in empty project - the interstitial ads were showing and events were fired well. But when I am trying to integrate the plugin with my game - the interstitial ads are showing but events are not firing. I thought that it caused because of another plugin integrated with my game, but I tried also remove all the plugins and integrate only admob, and interstitial ads are showing but events still are not firing.

Here is my AdMobManager: using System; using UnityEngine; using System.Collections; using GoogleMobileAds.Api;

 public class AdMobManager : MonoBehaviour {
 
     public static AdMobManager Instance{ get; private set; }
 
     private InterstitialAd _interstitial;
     private Action _callback;
 #if UNITY_ANDROID
     string adUnitId = "MyAdUnitId";
 #elif UNITY_IPHONE
     string adUnitId = "MyAdUnitId";
 #else
     string adUnitId = "unexpected_platform";
 #endif
 
     void Awake(){
         if (Instance == null)
             Instance = this;
         else if (Instance != null)
             Destroy (gameObject);
 
         DontDestroyOnLoad (gameObject);
     }
 
     void Start(){
 
 
         // Initialize an InterstitialAd.
         //_interstitial = new InterstitialAd(adUnitId);
 
         //SignEventsToHandlers ();
     }
 
     //Events handlers
     void OnAdClosed (object sender, System.EventArgs e){
         Debug.Log (string.Format ("AdMob.AdClosed - OK. sender: {0}, eventArgs: {1}", sender, e));
         if (_callback != null) _callback();
         else Debug.Log("_callback is null");
     }
 
     void OnAdClosing (object sender, System.EventArgs e){
         Debug.Log (string.Format ("AdMob.AdClosing - OK. sender: {0}, eventArgs: {1}", sender, e));
     }
 
     //void OnAdFailedLoad (object sender, AdFailedToLoadEventArgs e){
     //    Debug.Log (string.Format ("AdMob.AdFailedLoad - OK. sender: {0}, eventArgs: {1}", sender, e));
     //}
 
     //void OnAdLeftApplication (object sender, System.EventArgs e){
     //    Debug.Log (string.Format ("AdMob.AdLeftApplication - OK. sender: {0}, eventArgs: {1}", sender, e));
     //}
 
     private void OnAdLoaded(object sender, System.EventArgs e){
         Debug.Log(string.Format("AdMob.AdLoaded - OK. sender: {0}, eventArgs: {1}", sender, e));
     }
 
     private void OnAdOpened(object sender, System.EventArgs e){
         Debug.Log(string.Format("AdMob.AdOpened - OK. sender: {0}, eventArgs: {1}", sender, e));
     }
 
     //Public interface
     public void ShowInterstital(Action callback){
         //if (IapManager.Instance.IsXlPackBought) return;
         _callback = callback;
         if (_interstitial.IsLoaded())
             _interstitial.Show();
     }
 
     //TODO: Every time to show interstital animation I need to request this ad from server, check if it was loaded successfully and then show it
     //TODO: Or mayby to see on events. Maybe there event something like this: OnInterstitial loaded;
 
     //Actions
     public void RequestInterstitial(){
         // Create an empty ad request.
 #if UNITY_IOS
         AdRequest request = new AdRequest.Builder ().AddTestDevice (GameTools.GetIOSAdMobID ()).Build ();
         // Load the interstitial with the request.
         _interstitial.LoadAd(request);
 #endif
 #if UNITY_ANDROID
         _interstitial = new InterstitialAd(adUnitId);
         _interstitial.AdClosed += OnAdClosed;
         _interstitial.AdClosing += OnAdClosing;
         _interstitial.AdLoaded += OnAdLoaded;
         _interstitial.AdOpened += OnAdOpened;
         AdRequest request = new AdRequest.Builder()
                 .AddTestDevice(AdRequest.TestDeviceSimulator)
                 .AddTestDevice("E6CDB888557BA9A0") // My device ID
                 .AddKeyword("game")
                 .SetGender(Gender.Male)
                 .SetBirthday(new DateTime(1985, 1, 1))
                 .TagForChildDirectedTreatment(false)
                 .AddExtra("color_bg", "9B30FF")
                 .Build();
         _interstitial.LoadAd(request);
         
 #endif
     }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KrlinM · Mar 20, 2016 at 07:06 PM

Same here, events are not firing. Did you figure out it?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

AdMob iOS and Android 1 Answer

unity 5 2d game admob interstitial not working 0 Answers

Where to put AdMob mediation adapter files in Unity? 2 Answers

Admob Memory Issues 0 Answers

Unity Admob Implementing Interstitial 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges