Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

iAd Implementation

Discussion in 'Scripting' started by WinRupe, Jun 11, 2014.

  1. WinRupe

    WinRupe

    Joined:
    Mar 31, 2014
    Posts:
    4
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Yeah, I've got a question, is that all you need for proper iAd implementation? I have several concerns, one of them being error handling. If the banner gets an error, what should we do (as unity programmers)? Should we discard the AdBannerView and Instantiate a new one? Any ideas?
     
  3. WinRupe

    WinRupe

    Joined:
    Mar 31, 2014
    Posts:
    4
    That's a valid question, as you wouldn't want something as simple as a banner crashing your product. Here's the scripting reference from which I pulled the 'ADBannerView' class:
    http://docs.unity3d.com/ScriptReference/ADBannerView.html
    From what I can tell, there is no built in variable that allows you access to backend error checking, other than 'loaded' or 'onBannerWasLoaded,' which will postpone any further chosen action until an ad has been received.
    That being said, if truly concerned, you could wrap the initial loading call in a good ol' fashioned try-catch block.
    Code (CSharp):
    1. try
    2. {
    3.     banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Top);
    4.     ADBannerView.onBannerWasLoaded += OnBannerLoaded;
    5. }
    6. catch(UnityException error)
    7. {
    8.      Debug.Log(error);
    9. }
     
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Interesting, they must have taken the error checking functionality out just recently. It used to have an "error" property that you could poll to see if it has an error or not. We probably don't even need to check for errors ourselves.