/// <summary> /// ネイティブ広告の取得を行います /// </summary> /// <param name="spotId">スポットID</param> /// <param name="adParams">ネイティブ広告取得時のパラメータ</param> /// <param name="callBack">広告取得完了に実行されます</param> /// <param name="dontDestroyReciever">シーン間で広告を引き継ぐ際にTrueを指定します</param> /// <param name="adViewId">(省略可能)adViewIdを既に取得している場合、それを指定できます</param> public static int getNativeAdData(string spotId, IMobileNativeAdParams adParams, Action <IMobileNativeAdObject[]> callBack, bool dontDestroyReciever = false) { int adViewId = IMobileAdViewIdManager.CreateId(); #if !UNITY_EDITOR string partnerId = IMobileSpotInfoManager.GetPartnerId(spotId); string mediaId = IMobileSpotInfoManager.GetMediaId(spotId); string recieverGameObjectName = IMobileNativeAdRecieverManager.CreateNativeAdReciever(adViewId, callBack, dontDestroyReciever); #endif #if UNITY_IPHONE && !UNITY_EDITOR if (Application.platform == RuntimePlatform.IPhonePlayer) { string[] parameters = { partnerId, mediaId, spotId, adParams.requestAdCount.ToString(), adParams.nativeImageGetFlag.ToString(), recieverGameObjectName, adViewId.ToString() }; string paramStr = string.Join(":", parameters); imobileGetNativeAdDataAndNativeAdParams_(paramStr); } #elif UNITY_ANDROID && !UNITY_EDITOR if (Application.platform == RuntimePlatform.Android) { imobileSdkAdsAndroidPlugin.CallStatic( "getNativeAdData", partnerId, mediaId, spotId, adParams.requestAdCount, adParams.nativeImageGetFlag, recieverGameObjectName ); } #endif return(adViewId); }
void OnDisable() { if (!isDontDestroy) { IMobileNativeAdRecieverManager.RemoveRecieverFromDictionary(adViewId); } if (hasReceivedNativeAd) { #if UNITY_IPHONE && !UNITY_EDITOR if (Application.platform == RuntimePlatform.IPhonePlayer) { IMobileSdkAdsUnityPlugin.destroyNativeAd(adViewId); } #elif UNITY_ANDROID && !UNITY_EDITOR if (Application.platform == RuntimePlatform.Android) { IMobileSdkAdsUnityPlugin.getAndroidClass().CallStatic("destroyNativeAd", this.gameObject.name); } #endif } }
/// <summary> /// 対象adViewIDのレシーバーをDestroyします。 /// </summary> /// <param name="adViewId">adViewId</param> public static bool destroyReciever(int adViewId) { return(IMobileNativeAdRecieverManager.DestroyReciever(adViewId)); }
/// <summary> /// 対象adViewIDのレシーバーに設定されているcallBackを書き換えます。 /// </summary> /// <param name="spotid">スポットID</param> public static bool replaceCallBack(int adViewId, Action <IMobileNativeAdObject[]> callBack) { return(IMobileNativeAdRecieverManager.ReplaceRecieverCallBack(adViewId, callBack)); }