Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

iAd discussion question

Discussion in 'iOS and tvOS' started by DexRobinson, Feb 27, 2012.

  1. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    So how do you use it? What are the steps in Unity?
     
  2. Deleted User

    Deleted User

    Guest

    Attach it to a GameObject in your first scene. But try to read and understand it, first.
     
  3. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Yeah that's what I did but nothing displayed on my device. I think it's because a lot of the code is disabled or ignored. You know like how you use // to do that, but I don't see you using that so how can this be? Do I have to retype the whole code in order for it to enable?
     
  4. Deleted User

    Deleted User

    Guest

    Oh, right, I define FUGU_ADS as a preprocessor definition (see the #if statements) to activate/deactivate ads so I can build ad and ad-free versions without deactivating or removing the script. If you're not familiar with that, look for it in the Unity Manual (it's in some section called platform-dependent compilation or something like that). Once you're familiar with that, you can either set the definition in your Player Settings or just edit the script and remove anything you don't need (which will actually make it more readable)
     
  5. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Yeah I'm not familiar with it at all. I'll have to read up on it. By the way, do you know if it's possible to implement ads in Xcode on a Unity built app? I've seen many tutorials on Youtube but they all create a new Xcode project, and do not use Unity. So I was wondering if implementing ads through Unity and not on Xcode is the only way.
     
  6. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Oh and also, how can I change a certain script to only have ads in 1 scene? The script I currently use is working fine(minus a few loading issues such as a white banner) but it displays ads in every scene. So how can I change that? Script:

    Code (CSharp):
    1. public class IAdScript : MonoBehaviour {
    2.  
    3.     private ADBannerView banner = null;
    4.     void Start()
    5.     {
    6.         banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Bottom);
    7.         ADBannerView.onBannerWasClicked += OnBannerClicked;
    8.         ADBannerView.onBannerWasLoaded  += OnBannerLoaded;
    9.     }
    10.  
    11.     void OnBannerClicked()
    12.     {
    13.         Debug.Log("Clicked!\n");
    14.     }
    15.  
    16.     void OnBannerLoaded()
    17.     {
    18.         Debug.Log("Loaded!\n");
    19.         banner.visible = true;
    20.     }
    21. }
    I only have this script on an empty game object in the main menu scene, but the ads appear on every scene. Is this supposed to happen?
     
    Last edited: Aug 25, 2014
  7. Deleted User

    Deleted User

    Guest

    There are many examples of third-party plugins for iAd. Look at prime31.com, for example.
     
  8. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Well I did not mean third party but I'll assume the answer to my question is no, since you mention third part plugins. What about the script I posted? Can I stop it from appearing in every scene? Does Prime31 allow for that? Or is it the same as using the script I'm using now? There aren't many helpful tutorials on the web, and the thread for prime31 is dead.
     
  9. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    I am searching how to know if iAd is working in the user's country or if the iAd failed to load at least ?

    There is just an event for "onBannerWasLoaded" but none if it fails ?
     
  10. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    The doc seems to suggest that "isAvailable" only check the ios version :

    IsAvailable: Checks if the banner type is available (e.g. MediumRect is available only starting with os6).​
     
  11. hunter_Abraham

    hunter_Abraham

    Joined:
    Mar 26, 2014
    Posts:
    1
    @technicat, So you don't need to use any plugins now and the ads will be accepted by Itunes and working on Iphones?
     
  12. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    yes you don't need plugin for iAds, just Unity can be enough. If you want to remove the banner from the screen you can do :

    banner.visible = false;
    banner = null;

    Something like that should remove the banner.

    My game has been accepted with iAds banner using Unity only
    (Icy Run : https://itunes.apple.com/app/id914000131)
     
  13. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    I tried your game and it seemed the ad is the same again and again. Is the ad supposed to change? Or is the same one ad just been hidden and shown again? Or is it the iAd server sending same ad like this anyways.
     
  14. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    If you don't mind I'll share my experience. When I first loaded my game it gave me a StarBucks ad. Now after playing it for a little while it finally changed to something else. So I believe it changes overtime, just not very quickly.
     
  15. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    I think iAds will try to show the same one as long as it didnt display for at least 30s in total and then eventually change.

    I don't control how and what is downloaded everything is handled by iAd. So here its probably iAd sending the same ad.
     
  16. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    I have no idea how iAd really works, but I was just wondering if the banner should each time be loaded from a clean slate. You know, delete the banner after user has seen it then load it again next time instead of only showing and hiding "the same banner" with banner.visible.

    In the docs it says:

    "Please note that if you hide banner, ads might not be reloaded with time, so if you no longer need banner it is better to delete it completely."

    http://docs.unity3d.com/ScriptReference/ADBannerView-visible.html
     
  17. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    I'm not sur what they mean in the doc. From what i understood iAds keep resquesting ads forever every 30s or so and try to show it on screen. If you hide the banner iAd will still request ads but will detect that you are not showing it, so may be at some point it stop trying to request ads if there is too much failing.