diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml index b7fc823b..74d510c0 100644 --- a/Assets/Plugins/Android/AndroidManifest.xml +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -98,25 +98,6 @@ android:name="com.facebook.ads.AudienceNetworkActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> - - - - - - - - - /// Use this class to show offerwall ads. - /// - public class HZOfferWallAd : MonoBehaviour { - - public delegate void AdDisplayListener(string state, string tag); - private static AdDisplayListener adDisplayListener; - - public delegate void VirtualCurrencyResponseListener(VirtualCurrencyResponse response); - private static VirtualCurrencyResponseListener virtualCurrencyResponseListener; - - public delegate void VirtualCurrencyErrorListener(string errorMsg); - private static VirtualCurrencyErrorListener virtualCurrencyErrorListener; - - private static HZOfferWallAd _instance = null; - - //provided since JS can't use default parameters - /// - /// Shows an ad with the default options. - /// - public static void Show() { - HZOfferWallAd.ShowWithOptions(null); - } - /// - /// Shows an ad with the given options. - /// - /// The options to show the ad with, or the default options if null - public static void ShowWithOptions(HZOfferWallShowOptions showOptions) { - if (showOptions == null) { - showOptions = new HZOfferWallShowOptions(); - } - - #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE) - #if UNITY_ANDROID - HZOfferWallAdAndroid.ShowWithOptions(showOptions); - #elif UNITY_IPHONE - HZOfferWallAdIOS.ShowWithOptions(showOptions); - #endif - #else - UnityEngine.Debug.LogWarning("Call received to show an HZOfferWallAd, but the SDK does not function in the editor. You must use a device/emulator to fetch/show ads."); - _instance.StartCoroutine(InvokeCallbackNextFrame(HeyzapAds.NetworkCallback.SHOW_FAILED, showOptions.Tag)); - #endif - } - - //provided since JS can't use default parameters - /// - /// Fetches an ad for the default ad tag. - /// - public static void Fetch() { - HZOfferWallAd.Fetch(null); - } - /// - /// Fetches an ad for the given ad tag. - /// - /// The ad tag to fetch an ad for. - public static void Fetch(string tag) { - tag = HeyzapAds.TagForString(tag); - - #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE) - #if UNITY_ANDROID - HZOfferWallAdAndroid.Fetch(tag); - #elif UNITY_IPHONE - HZOfferWallAdIOS.Fetch(tag); - #endif - #else - UnityEngine.Debug.LogWarning("Call received to fetch an HZOfferWallAd, but the SDK does not function in the editor. You must use a device/emulator to fetch/show ads."); - _instance.StartCoroutine(InvokeCallbackNextFrame(HeyzapAds.NetworkCallback.FETCH_FAILED, tag)); - #endif - } - - //provided since JS can't use default parameters - /// - /// Returns whether or not an ad is available for the default ad tag. - /// - /// true, if an ad is available, false otherwise. - public static bool IsAvailable() { - return HZOfferWallAd.IsAvailable(null); - } - /// - /// Returns whether or not an ad is available for the given ad tag. - /// - /// true, if an ad is available, false otherwise. - public static bool IsAvailable(string tag) { - tag = HeyzapAds.TagForString(tag); - - #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE) - #if UNITY_ANDROID - return HZOfferWallAdAndroid.IsAvailable(tag); - #elif UNITY_IPHONE - return HZOfferWallAdIOS.IsAvailable(tag); - #endif - #else - return false; - #endif - } - - /// - /// Sends a request to the Virtual Currency Server to see if the user has earned virtual currency since the last request. - /// The `VirtualCurrencyResponseListener` or the `VirtualCurrencyErrorListener` will receive the response once received. - /// - /// The ID of the currency to request information about. Setting this to NULL will request the default currency. - public static void RequestDeltaOfCurrency(string currencyId) { - #if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE) - #if UNITY_ANDROID - HZOfferWallAdAndroid.RequestDeltaOfCurrency(currencyId); - #elif UNITY_IPHONE - HZOfferWallAdIOS.RequestDeltaOfCurrency(currencyId); - #endif - #else - UnityEngine.Debug.LogWarning("Call received to request a VCS update on HZOfferWallAd, but the SDK does not function in the editor. You must use a device/emulator to do this."); - _instance.StartCoroutine(InvokeVCSErrorNextFrame("only_works_on_device")); - #endif - } - - /// - /// Sets the AdDisplayListener for offerwall ads, which will receive callbacks regarding the state of offerwall ads. - /// - public static void SetDisplayListener(AdDisplayListener listener) { - HZOfferWallAd.adDisplayListener = listener; - } - - /// - /// Sets the VirtualCurrencyResponseListener for offerwall ads, which will receive callbacks in response to a request for a VCS update. - /// - public static void SetVirtualCurrencyResponseListener(VirtualCurrencyResponseListener listener) { - HZOfferWallAd.virtualCurrencyResponseListener = listener; - } - - /// - /// Sets the VirtualCurrencyErrorListener for offerwall ads, which will receive callbacks regarding errors received after requesting virtual currency updates from the server. - /// - public static void SetVirtualCurrencyErrorListener(VirtualCurrencyErrorListener listener) { - HZOfferWallAd.virtualCurrencyErrorListener = listener; - } - - #region Internal methods - public static void InitReceiver(){ - if (_instance == null) { - GameObject receiverObject = new GameObject("HZOfferWallAd"); - DontDestroyOnLoad(receiverObject); - _instance = receiverObject.AddComponent(); - } - } - - // received from native SDK - public void SetCallback(string message) { - string[] displayStateParams = message.Split(','); - HZOfferWallAd.SetCallbackStateAndTag(displayStateParams[0], displayStateParams[1]); - } - protected static void SetCallbackStateAndTag(string state, string tag) { - if (HZOfferWallAd.adDisplayListener != null) { - HZOfferWallAd.adDisplayListener(state, tag); - } - } - - // used for in-editor functionality - protected static IEnumerator InvokeCallbackNextFrame(string state, string tag) { - yield return null; // wait a frame - HZOfferWallAd.SetCallbackStateAndTag(state, tag); - } - - // received from native SDK - public void VCSResponse(string jsonString) { - HZOfferWallAd.SendVCSResponse(jsonString); - } - protected static void SendVCSResponse(string jsonString) { - if (HZOfferWallAd.virtualCurrencyResponseListener != null) { - VirtualCurrencyResponse response = (VirtualCurrencyResponse)JsonUtility.FromJson(jsonString); - HZOfferWallAd.virtualCurrencyResponseListener(response); - } - } - - // received from native SDK - public void VCSError(string errorMsg) { - HZOfferWallAd.SendVCSError(errorMsg); - } - protected static void SendVCSError(string errorMsg) { - if (HZOfferWallAd.virtualCurrencyErrorListener != null) { - HZOfferWallAd.virtualCurrencyErrorListener(errorMsg); - } - } - - // used for in-editor functionality - protected static IEnumerator InvokeVCSErrorNextFrame(string errorMsg) { - yield return null; // wait a frame - HZOfferWallAd.SendVCSError(errorMsg); - } - #endregion - } - - #region Platform-specific translations - #if UNITY_IPHONE && !UNITY_EDITOR - public class HZOfferWallAdIOS : MonoBehaviour { - [DllImport ("__Internal")] - private static extern void hz_ads_show_offerwall(string tag, bool shouldCloseAfterFirstClick); - [DllImport ("__Internal")] - private static extern void hz_ads_fetch_offerwall(string tag); - [DllImport ("__Internal")] - private static extern bool hz_ads_offerwall_is_available(string tag); - [DllImport ("__Internal")] - private static extern bool hz_ads_virtual_currency_request(string currencyId); - - - public static void ShowWithOptions(HZOfferWallShowOptions showOptions) { - hz_ads_show_offerwall(showOptions.Tag, showOptions.ShouldCloseAfterFirstClick); - } - - public static void Fetch(string tag) { - hz_ads_fetch_offerwall(tag); - } - - public static bool IsAvailable(string tag) { - return hz_ads_offerwall_is_available(tag); - } - - public static void RequestDeltaOfCurrency(string currencyId) { - hz_ads_virtual_currency_request(currencyId); - } - } - #endif - - #if UNITY_ANDROID && !UNITY_EDITOR - public class HZOfferWallAdAndroid : MonoBehaviour { - - public static void ShowWithOptions(HZOfferWallShowOptions showOptions) { - if(Application.platform != RuntimePlatform.Android) return; - - AndroidJNIHelper.debug = false; - using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) { - jc.CallStatic("showOfferWall", showOptions.Tag, showOptions.ShouldCloseAfterFirstClick); - } - } - - public static void Fetch(string tag) { - if(Application.platform != RuntimePlatform.Android) return; - - AndroidJNIHelper.debug = false; - using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) { - jc.CallStatic("fetchOfferWall", tag); - } - } - - public static Boolean IsAvailable(string tag) { - if(Application.platform != RuntimePlatform.Android) return false; - - AndroidJNIHelper.debug = false; - using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) { - return jc.CallStatic("isOfferWallAvailable", tag); - } - } - - public static void RequestDeltaOfCurrency(string currencyId) { - if(Application.platform != RuntimePlatform.Android) return; - - AndroidJNIHelper.debug = false; - using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) { - jc.CallStatic("virtualCurrencyRequest", currencyId); - } - } - } - #endif - #endregion - - [Serializable] - public class VirtualCurrencyResponse { - public string LatestTransactionID; - public string CurrencyID; - public string CurrencyName; - public float DeltaOfCurrency; - } -} diff --git a/Assets/Plugins/Heyzap/HZShowOptions.cs b/Assets/Plugins/Heyzap/HZShowOptions.cs index 482e90d8..de203fd3 100644 --- a/Assets/Plugins/Heyzap/HZShowOptions.cs +++ b/Assets/Plugins/Heyzap/HZShowOptions.cs @@ -86,26 +86,4 @@ public string Position { } private string position = HZBannerShowOptions.DEFAULT_POSITION; } - - /// - /// A set of options that describes how to show an offerwall ad. - /// - public class HZOfferWallShowOptions : HZShowOptions { - private const bool DEFAULT_SHOULD_CLOSE_AFTER_FIRST_CLICK = true; - - /// - /// When an incentivized video is completed, this string will be sent to your server via our server-to-server callbacks. Set it to anything you want to pass to your server regarding this incentivized video view (i.e.: a username, user ID, level name, etc.), or leave it empty if you don't need to use it / aren't using server callbacks for incentivized video. - /// More information about using this feature can be found at https://developers.heyzap.com/docs/advanced-publishing . - /// Guaranteed to be non-null - will be set to the default value if the setter is called with `null`. - /// - public bool ShouldCloseAfterFirstClick { - get { - return shouldCloseAfterFirstClick; - } - set { - shouldCloseAfterFirstClick = value; - } - } - private bool shouldCloseAfterFirstClick = HZOfferWallShowOptions.DEFAULT_SHOULD_CLOSE_AFTER_FIRST_CLICK; - } } \ No newline at end of file diff --git a/Assets/Plugins/Heyzap/HeyzapAds.cs b/Assets/Plugins/Heyzap/HeyzapAds.cs index 7f180e3d..fa4a3489 100644 --- a/Assets/Plugins/Heyzap/HeyzapAds.cs +++ b/Assets/Plugins/Heyzap/HeyzapAds.cs @@ -153,7 +153,6 @@ public static void Start(string publisher_id, int options) { HZVideoAd.InitReceiver(); HZIncentivizedAd.InitReceiver(); HZBannerAd.InitReceiver(); - HZOfferWallAd.InitReceiver(); HZDemographics.InitReceiver(); } diff --git a/Assets/Scripts/AdManager.cs b/Assets/Scripts/AdManager.cs index b2f84a5e..bb9227b0 100644 --- a/Assets/Scripts/AdManager.cs +++ b/Assets/Scripts/AdManager.cs @@ -12,22 +12,15 @@ public class AdManager : MonoBehaviour { [SerializeField] private GameObject bannerControls; [SerializeField] - private GameObject offerwallControls; - [SerializeField] private GameObject standardControls; [SerializeField] private ScrollingTextArea console; - [SerializeField] - private Toggle offerwallCloseOnFirstClickToggle; - [SerializeField] - private Text offerwallCurrencyIdTextField; private enum AdType { Interstitial, Video, Incentivized, - Banner, - Offerwall + Banner } private AdType _selectedAdType; @@ -50,7 +43,6 @@ void Awake() { this.adTagTextField.MustNotBeNull(); this.bannerControls.MustNotBeNull(); this.standardControls.MustNotBeNull(); - this.offerwallControls.MustNotBeNull(); this.console.MustNotBeNull(); } @@ -72,7 +64,7 @@ void Start () { HeyzapAds.SetNetworkCallbackListener(networkCallbackListener); HeyzapAds.ShowDebugLogs(); - HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS); + HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS); HZBannerAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("BANNER: " + adState + " Tag : " + adTag); @@ -95,18 +87,6 @@ void Start () { this.console.Append("VIDEO: " + adState + " Tag : " + adTag); }); - HZOfferWallAd.SetDisplayListener(delegate(string adState, string adTag) { - this.console.Append("OFFERWALL: " + adState + " Tag : " + adTag); - }); - - HZOfferWallAd.SetVirtualCurrencyResponseListener(delegate(VirtualCurrencyResponse response) { - this.console.Append("OFFERWALL VCS Response: id:" + response.CurrencyID + " name: '" + response.CurrencyName + "' amount : " + response.DeltaOfCurrency + " trans: " + response.LatestTransactionID); - }); - - HZOfferWallAd.SetVirtualCurrencyErrorListener(delegate(string errorMsg) { - this.console.Append("OFFERWALL VCS Error: " + errorMsg); - }); - // UI defaults this.bannerPosition = HZBannerShowOptions.POSITION_TOP; this.SelectedAdType = AdType.Interstitial; @@ -138,12 +118,6 @@ public void BannerSelected(bool selected) { } } - public void OfferwallSelected(bool selected) { - if (selected) { - this.SelectedAdType = AdType.Offerwall; - } - } - public void IsAvailableButton() { string tag = this.adTag(); bool available = false; @@ -161,9 +135,6 @@ public void IsAvailableButton() { case AdType.Banner: // Not applicable break; - case AdType.Offerwall: - available = HZOfferWallAd.IsAvailable(tag); - break; } string availabilityMessage = available ? "available" : "not available"; @@ -184,10 +155,6 @@ public void ShowButton() { bannerOptions.Tag = tag; bannerOptions.Position = this.bannerPosition; - HZOfferWallShowOptions offerwallOptions = new HZOfferWallShowOptions(); - offerwallOptions.ShouldCloseAfterFirstClick = offerwallCloseOnFirstClickToggle.isOn; - offerwallOptions.Tag = tag; - this.console.Append("Showing " + this.SelectedAdType.ToString() + " with tag: " + tag); switch (this.SelectedAdType) { case AdType.Interstitial: @@ -202,9 +169,6 @@ public void ShowButton() { case AdType.Banner: HZBannerAd.ShowWithOptions(bannerOptions); break; - case AdType.Offerwall: - HZOfferWallAd.ShowWithOptions(offerwallOptions); - break; } } @@ -221,9 +185,6 @@ public void FetchButton() { case AdType.Incentivized: HZIncentivizedAd.Fetch(tag); break; - case AdType.Offerwall: - HZOfferWallAd.Fetch(tag); - break; } } @@ -325,10 +286,6 @@ public void BannerPositionBottom(bool selected) { } } - public void VCSRequestButton() { - HZOfferWallAd.RequestDeltaOfCurrency(this.currencyId()); - } - public void ShowMediationTest() { this.console.Append("Showing mediation test suite"); HeyzapAds.ShowMediationTestSuite(); @@ -338,14 +295,8 @@ private void ShowAdTypeControls() { if (this.SelectedAdType == AdType.Banner) { this.bannerControls.SetActive(true); this.standardControls.SetActive(false); - this.offerwallControls.SetActive(false); - } else if (this.SelectedAdType == AdType.Offerwall) { - this.bannerControls.SetActive(false); - this.offerwallControls.SetActive(true); - this.standardControls.SetActive(false); } else { this.bannerControls.SetActive(false); - this.offerwallControls.SetActive(false); this.standardControls.SetActive(true); } } @@ -358,13 +309,4 @@ private string adTag() { return tag; } } - - private string currencyId() { - string currencyId = this.offerwallCurrencyIdTextField.text; - if (currencyId == null || tag.Trim().Length == 0) { - return null; - } else { - return currencyId; - } - } }