Prime31 iAd plugin testing

Hi all,

I’ve just bought prime31’s iAd plugin and added it to my unity app, but when i do a dev build to my phone I can’t see the banner or any test ads. I’ve been reading a lot of forums and getting mixed responses on whether test ads work or not. Can anybody who has used this plugin confirm that you can receive tests ads from a debug build?

Thanks

any update on this? i am going to use the plugin. If you could give a simple step by step tutorial, that will be nice.
and i have a question. Can i only put the prefab in the first scene or any scene?

Hi Shamssd,

Yes I did solve the problem in the end and it was a problem with my iAds settings, not the plugin - my bad…
The plugins great and simple, just drag the prefab into your scene (can be any, doesn’t have to be first) and it jut works. Hope that helps.

thanks Pseidus. I will try this.
Again i wish i could use unity 3.5. it has built is support for iad.

Hello All,

I am also facing the problem with iAd plugin that i have just bought from prime31’s. i added it to my unity app, but i can not get any responses on whether test ads will show or not on the screen. Can anybody who has used this plugin let me know how to check the response from apple server for iAds…???

Thanks:
Niki.j

Hello guys…

Any update…???

please find the code that i am trying:

AdManager.cs

using UnityEngine;
using System;
using System.Collections;
using Prime31;


#if UNITY_IPHONE
public class AdManager : AbstractManager
{
	// Fired when the adView is either shown or hidden
	public static event Action<bool> adViewDidChange;
	
	// Fired when an interstial ad fails to load or show
	public static event Action<string> interstitalAdFailed;
	
	// Fired when an interstitial ad is loaded and ready to show
	public static event Action interstitialAdLoaded;
	
	public static bool adViewIsShowing = false;
	
	private string mystr;
	public static bool isAdVisible;
	
    static AdManager()
    {
		AbstractManager.initialize( typeof( AdManager ) );
    }

	public void adViewDidShow(string returnValue)
	{
		adViewIsShowing = ( returnValue == "1" );
		adViewDidChange.fire( adViewIsShowing );
		Debug.Log("nitin iAd called ->"+ returnValue);
		mystr = returnValue;
		if(mystr == "1")
			isAdVisible = true;
		else
			isAdVisible = false;
	}
	
	public void interstitialFailed( string error )
	{
		interstitalAdFailed.fire( error );
	}
	
	
	public void interstitialLoaded( string empty )
	{
		interstitialAdLoaded.fire();
	}
}
#endif

AdBinding.cs

using UnityEngine;
using System.Runtime.InteropServices;


public static class AdBinding
{
    [DllImport("__Internal")]
    private static extern void _iAdCreateAdBanner( bool bannerOnBottom );

	// Starts up iAd requests and ads the ad view
    public static void createAdBanner( bool bannerOnBottom )
    {
        // Call plugin only when running on real device
        if( Application.platform == RuntimePlatform.IPhonePlayer )
			_iAdCreateAdBanner( bannerOnBottom );
    }
	
    [DllImport("__Internal")]
    private static extern void _iAdDestroyAdBanner();

	// Destroys the ad banner and removes it from view
    public static void destroyAdBanner()
    {
        // Call plugin only when running on real device
        if( Application.platform == RuntimePlatform.IPhonePlayer )
			_iAdDestroyAdBanner();
    }	


    [DllImport("__Internal")]
    private static extern void _iAdFireHideShowEvents( bool shouldFire );

	// Switches the orientation of the ad view
    public static void fireHideShowEvents( bool shouldFire )
    {
        // Call plugin only when running on real device
		Debug.Log("in AdBinding -> fireHideShowEvents -> shouldFire = " + shouldFire);
		
        if( Application.platform == RuntimePlatform.IPhonePlayer )
			_iAdFireHideShowEvents( shouldFire );
    }


	[DllImport("__Internal")]
	private static extern bool _iAdInitializeInterstitial();

	// Starts loading a new interstitial ad.  Returns false when interstitials are not supported.
	public static bool initializeInterstitial()
	{
		if( Application.platform == RuntimePlatform.IPhonePlayer )
			return _iAdInitializeInterstitial();

		return false;
	}


	[DllImport("__Internal")]
	private static extern bool _iAdInterstitialIsLoaded();

	// Checks to see if an interstitial ad is loaded.
	public static bool isInterstitalLoaded()
	{
		if( Application.platform == RuntimePlatform.IPhonePlayer )
			return _iAdInterstitialIsLoaded();

		return false;
	}


	[DllImport("__Internal")]
	private static extern bool _iAdShowInterstitial();

	// Shows an interstitial ad.  Will return false if it isn't loaded.
	public static bool showInterstitial()
	{
		if( Application.platform == RuntimePlatform.IPhonePlayer )
			return _iAdShowInterstitial();

		return false;
	}
	
}

the code where i am calling all the required functions are:

void Update()
    {
		if(Time.frameCount % 10 == 0)
		{
			AdBinding.fireHideShowEvents(true);
			AdBinding.createAdBanner();
		}
	}

I am able to show the iAds but i need to decrease the size of screen when iAd will come on the screen, to do that i am looking for any response from the server end, but not able to get that, please help me if any one having any idea bout my problem…

Thanks in Advance!
Niki.j

I would think the person/company that took your money should have help for you.

TRY HERE

:slight_smile:

Hello Greg,

Thanks for the help,
I got that, there is an event “adViewDidChange” in adManager class, but still i can not find how to get response with this event…???
Do you have any idea about this…???

Thanks
Niki.j

Hello,

Finally i have find the way.
here is the code for iAds…

using UnityEngine;

public class AdAdapter : MonoBehaviour
{
	public bool bannerOnBottom = true;
	public bool isAdShowing;
#if UNITY_IPHONE
	
	public void Start()
	{
		// start up iAd and destroy ourself
		AdBinding.createAdBanner( bannerOnBottom );
		AdBinding.fireHideShowEvents(true);
		AdManager.adViewDidChange += HandleAdManageradViewDidChange;
		//Destroy( gameObject );
	}

	void HandleAdManageradViewDidChange (bool obj)
	{
		isAdShowing = obj;
	}
#endif
}

any one just need to create an empty game object and assign this script on the same will start working for your iAds also you can get the response in isAdShowing as bool.