Hello All, I am using prime31 iAd_2013 plugin for the first time. There I want a response from the server when the ad gets displayed on the screen, so that i can decrease the my game play area accordingly. Also I want to show and hide the iAds, but i can not find any way to do this. Do any one have any solution for my problem...then please guide me. Thank you in advance for the help and sorry for rent. Niki.j
Hello guys... Any update...???? You can find the code here that i am trying: the code where i am calling all the required functions from the prime31 iAd plugin are: Code (csharp): void Update() { if(Time.frameCount % 10 == 0) { AdBinding.fireHideShowEvents(true); AdBinding.createAdBanner(); } } AdManager.cs Code (csharp): 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 Code (csharp): 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; } } 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
Hello, Finally i have find the way. here is the code for iAds..... Code (csharp): 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.