• 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 hhhdshsdfh · Sep 15, 2015 at 06:31 PM · androidadsunity adsadvertisinginitialization

Unity Ads doesn't Initialize properly

Hello, I recently published a game to the google play store, with unity ads. The ads work for most people but on my test device when I click to show the ad it doesn't appear. I have narrowed it down to a problem with Initialization, since tried running a loop that loops while (!Advertisemet.IsInitialzed){ Advertisement.Initialize("code", false) } also when I initialize with test units it works fine, so it has something to do with the internet connection I am guessing. And yet I am receiving emails and I can surf the web so it shouldn't be a problem with my device. Also I have initialized the ads as soon as the game opens. So I don't know what it wrong because it only happens on a limited number of devices. please help me.

This is the code that the button uses:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Advertisements;
 public class WatchUnityAd : MonoBehaviour
 {
     public int numOfCoinsToAdd = 5;
     bool paused = false,CRRuning = false;
     // Use this for initialization
     void Start()
     {
          //Advertisement.Initialize("66223",false);
     }
 
     public void ShowAd(string zone = "")
     {
 #if UNITY_EDITOR
         StartCoroutine(WaitForAd());
 #endif
         if (string.Equals(zone, ""))
             zone = null;
         /*while (!Advertisement.isInitialized)
         {
             Advertisement.Initialize("66223", false);
         }*/
         ShowOptions options = new ShowOptions();
         options.resultCallback = AdCallbackhandler;
 
         if (Advertisement.IsReady())
             Advertisement.Show(zone, options);
     }
 
     void AdCallbackhandler(ShowResult result)
     {
         switch (result)
         {
             case ShowResult.Finished:
                 Debug.Log("Ad Finished. Rewarding player...");
                 int coinTotal = PlayerPrefs.GetInt("coinTotal");
                 coinTotal += numOfCoinsToAdd;
                 PlayerPrefs.SetInt("coinTotal", coinTotal);
                 gameObject.SetActive(false);
                 break;
             case ShowResult.Skipped:
                 Debug.Log("Ad skipped. Son, I am dissapointed in you");
                 break;
             case ShowResult.Failed:
                 Debug.Log("I swear this has never happened to me before");
                 break;
         }
     }
 
     IEnumerator WaitForAd()
     {
         float currentTimeScale = Time.timeScale;
         Time.timeScale = 0f;
         yield return null;
 
         while (Advertisement.isShowing)
             yield return null;
 
         Time.timeScale = currentTimeScale;
     }
 }

PS. I implemented exactly the code that appears in the live session about unity ads, and all I did was that ShowAd() is run when a button is pressed. PPS. if you need me to give anymore information so you could help me let me know because this is an important fix for me because the game is already published.

Thank you!

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Unity Ads not showing when internet connect is regain. 1 Answer

Android build error when using Unity Ads 2 Answers

Chartboost adds are not showing up on android 0 Answers

ClassNotFoundException: com.unity.ads.IUnityAdsShowListener 1 Answer

Questions about Unity Ads implementation 2 Answers


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