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:
//for iAd banner
function OnGUI() {
GUI.enabled = (banner == null ? true : false);
banner = new ADBannerView();
banner.autoSize = true;
banner.autoPosition = ADPosition.Bottom;
StartCoroutine(ShowBanner());
}
//iAd function
function ShowBanner() {
while (!banner.loaded banner.error == null)
yield;
if (banner.error == null)
banner.Show();
else banner = null;
}
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
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?
neither. The problem was that I was putting the banner inside OnGUI, which is a loop function, instead change the function type to Start() and everything will be fine. My game is running on app store now, you can take a look https://itunes.apple.com/us/app/eagle-training/id638328088?ls=1&mt=8
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.