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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

iAd crashes my app

Discussion in 'iOS and tvOS' started by Wolves_Realm, Apr 12, 2013.

  1. Wolves_Realm

    Wolves_Realm

    Joined:
    Nov 30, 2009
    Posts:
    84
    Hi,
    Guys I need help, I created a game and put the iAd code, exactly the way it was written in unity script manual.
    HTML:
    http://docs.unity3d.com/Documentation/ScriptReference/ADBannerView.html
    I just removed the the line that generates a button to show the iAd so I wrote like this and added this to my main menu script in the scene:
    Code (csharp):
    1.  
    2. //for iAd banner
    3. function OnGUI() {
    4.     GUI.enabled = (banner == null ? true : false);
    5.    
    6.     banner = new ADBannerView();
    7.     banner.autoSize = true;
    8.     banner.autoPosition = ADPosition.Bottom;
    9.     StartCoroutine(ShowBanner());
    10. }
    11.  
    12. //iAd function
    13. function ShowBanner() {
    14.     while (!banner.loaded  banner.error == null)
    15.         yield;
    16.        
    17.     if (banner.error == null)
    18.         banner.Show();
    19.     else banner = null;
    20. }
    21.  
    when I ran the app on my iphone, the iAd sample "Sometimes" showed up and most of the times crashed the app (it was random). So I thought the crashes are because of the absence of an actual Ad, and I assumed that it would be fixed when I send it to app store. But now that my app is on app store, not a single app shows up and 90% of the time the app crashes upon the loading of the iAd. Do you guys have any ideas how to fix this?

    P.S. I have enabled iAd network on my iTunes connect and using unity 3.5.7f6
     
  2. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    Hi, i have the same problem...Also using Unity 3.5.7 and my framerate is well at 25-28 FPS but when the banner loads it goes down to 15-20 and when i click on the test banner from apple it seems to need a lot of memory for loading content and the app crash! Till now i also have no solution for this? Anybody have an idea to free programmaticaly memory when clicking on the banner? Mybe in Objective-c or Unity Javascript?

    Thanks
     
  3. Wolves_Realm

    Wolves_Realm

    Joined:
    Nov 30, 2009
    Posts:
    84
  4. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    no it isn't working....also when i call it once and not in gui loop. It always crashes when the iAd Test content is loading.
    What else can i do? Thanks
     
  5. Wolves_Realm

    Wolves_Realm

    Joined:
    Nov 30, 2009
    Posts:
    84
    the Unity code is fine, but the issue is that in the unity code there is a button that the user has to touch in order to reveal the ad banner. But in my case I just removed the button and that was the reason of the crash! because without the button function the iad banner code was running 100 times per frame resulting in a crash! So either use the button function which then requires you to put your function inside a OnGUI() function since a GUI element is involved; OR remove the button and place that code inside the Start() function, so it would be executed only once.
     
  6. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    hey thanks...so i know now that you forget the button for testing without looping in the OnGUI Function. Thats not my Problem.

    My Problem is when i click on the test iad banner... the content loads for 2-3 seconds and then crashes the app with error:

    PHP:
    viewServiceDidTerminateWithError:: Error Domain=XPCObjectsErrorDomain Code="The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)"
    Any idea?
     
  7. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi mikolo
    i face some issue with iad and unity 4.2, did u manage to solve your problem?