Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HZUNITY-73] Remove old APIs #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Assets/Fyber/Editor/Resources/FyberEditorSettings.asset
Binary file not shown.
206 changes: 38 additions & 168 deletions Assets/Plugins/Android/AndroidManifest.xml

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Assets/Plugins/Heyzap/HZBannerAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace Heyzap {
/// Use this class to show banner ads.
/// </summary>
public class HZBannerAd : MonoBehaviour {
public delegate void AdDisplayListener(string state, string tag);
public delegate void AdDisplayListener(string state, string placement);

private static AdDisplayListener adDisplayListener;
private static HZBannerAd _instance = null;
private static HZBannerAd _instance;

// these are reproduced here for convenience since they were here in old SDK versions
/// <summary>
Expand Down Expand Up @@ -70,7 +70,7 @@ public static void ShowWithOptions(HZBannerShowOptions showOptions) {
#endif
#else
UnityEngine.Debug.LogWarning("Call received to show an HZBannerAd, 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));
_instance.StartCoroutine(InvokeCallbackNextFrame(HeyzapAds.NetworkCallback.SHOW_FAILED, showOptions.Placement));
#endif
}

Expand Down Expand Up @@ -138,18 +138,18 @@ public static void InitReceiver(){

public void SetCallback(string message) {
string[] displayStateParams = message.Split(',');
HZBannerAd.SetCallbackStateAndTag(displayStateParams[0], displayStateParams[1]);
HZBannerAd.SetCallbackStateAndPlacement(displayStateParams[0], displayStateParams[1]);
}

protected static void SetCallbackStateAndTag(string state, string tag) {
protected static void SetCallbackStateAndPlacement(string state, string placement) {
if (HZBannerAd.adDisplayListener != null) {
HZBannerAd.adDisplayListener(state, tag);
HZBannerAd.adDisplayListener(state, placement);
}
}

protected static IEnumerator InvokeCallbackNextFrame(string state, string tag) {
protected static IEnumerator InvokeCallbackNextFrame(string state, string placement) {
yield return null; // wait a frame
HZBannerAd.SetCallbackStateAndTag(state, tag);
HZBannerAd.SetCallbackStateAndPlacement(state, placement);
}
#endregion
}
Expand All @@ -158,7 +158,7 @@ protected static IEnumerator InvokeCallbackNextFrame(string state, string tag) {
#if UNITY_IPHONE && !UNITY_EDITOR
public class HZBannerAdIOS : MonoBehaviour {
[DllImport ("__Internal")]
private static extern void hz_ads_show_banner(string position, string tag);
private static extern void hz_ads_show_banner(string position, string placement);
[DllImport ("__Internal")]
private static extern bool hz_ads_hide_banner();
[DllImport ("__Internal")]
Expand All @@ -168,7 +168,7 @@ public class HZBannerAdIOS : MonoBehaviour {


public static void ShowWithOptions(HZBannerShowOptions showOptions) {
hz_ads_show_banner(showOptions.Position, showOptions.Tag);
hz_ads_show_banner(showOptions.Position, showOptions.Placement);
}

public static bool Hide() {
Expand Down Expand Up @@ -230,7 +230,7 @@ public static void ShowWithOptions(HZBannerShowOptions showOptions) {

AndroidJNIHelper.debug = false;
using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) {
jc.CallStatic("showBanner", showOptions.Tag, showOptions.Position);
jc.CallStatic("showBanner", showOptions.Placement, showOptions.Position);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Plugins/Heyzap/HZBannerAd.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Plugins/Heyzap/HZDemographics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Heyzap {
/// </summary>
public class HZDemographics : MonoBehaviour {

private static HZDemographics _instance = null;
private static HZDemographics _instance;

public enum Gender {
UNKNOWN,
Expand Down
4 changes: 2 additions & 2 deletions Assets/Plugins/Heyzap/HZDemographics.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions Assets/Plugins/Heyzap/HZIncentivizedAd.cs.meta

This file was deleted.

74 changes: 35 additions & 39 deletions Assets/Plugins/Heyzap/HZInterstitialAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ namespace Heyzap {
/// </summary>
public class HZInterstitialAd : MonoBehaviour {

public delegate void AdDisplayListener(string state, string tag);
public delegate void AdDisplayListener(string state, string placement);
private static AdDisplayListener adDisplayListener;
private static HZInterstitialAd _instance = null;
private static HZInterstitialAd _instance;

//provided since JS can't use default parameters
/// <summary>
Expand All @@ -63,57 +63,53 @@ public static void ShowWithOptions(HZShowOptions showOptions) {
HZInterstitialAdIOS.ShowWithOptions(showOptions);
#endif
#else
UnityEngine.Debug.LogWarning("Call received to show an HZInterstitalAd, 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));
UnityEngine.Debug.LogWarning("Call received to show an HZInterstitialAd, 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.Placement));
#endif
}

//provided since JS can't use default parameters
/// <summary>
/// Fetches an ad for the default ad tag.
/// Fetches an ad for the default placement name.
/// </summary>
public static void Fetch() {
HZInterstitialAd.Fetch(null);
}
/// <summary>
/// Fetches an ad for the given ad tag.
/// Fetches an ad for the given placement name.
/// </summary>
/// <param name="tag">The ad tag to fetch an ad for.</param>
public static void Fetch(string tag) {
tag = HeyzapAds.TagForString(tag);

/// <param name="placement">The placement name to fetch an ad for.</param>
public static void Fetch(string placement) {
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HZInterstitialAdAndroid.Fetch(tag);
HZInterstitialAdAndroid.Fetch(placement);
#elif UNITY_IPHONE
HZInterstitialAdIOS.Fetch(tag);
HZInterstitialAdIOS.Fetch(placement);
#endif
#else
UnityEngine.Debug.LogWarning("Call received to fetch an HZInterstitialAd, 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));
_instance.StartCoroutine(InvokeCallbackNextFrame(HeyzapAds.NetworkCallback.FETCH_FAILED, placement));
#endif
}

//provided since JS can't use default parameters
/// <summary>
/// Returns whether or not an ad is available for the default ad tag.
/// Returns whether or not an ad is available for the default placement name.
/// </summary>
/// <returns><c>true</c>, if an ad is available, <c>false</c> otherwise.</returns>
public static bool IsAvailable() {
return HZInterstitialAd.IsAvailable(null);
}
/// <summary>
/// Returns whether or not an ad is available for the given ad tag.
/// Returns whether or not an ad is available for the given placement name.
/// </summary>
/// <returns><c>true</c>, if an ad is available, <c>false</c> otherwise.</returns>
public static bool IsAvailable(string tag) {
tag = HeyzapAds.TagForString(tag);

public static bool IsAvailable(string placement) {
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
return HZInterstitialAdAndroid.IsAvailable(tag);
return HZInterstitialAdAndroid.IsAvailable(placement);
#elif UNITY_IPHONE
return HZInterstitialAdIOS.IsAvailable(tag);
return HZInterstitialAdIOS.IsAvailable(placement);
#endif
#else
return false;
Expand Down Expand Up @@ -183,18 +179,18 @@ public static void InitReceiver(){

public void SetCallback(string message) {
string[] displayStateParams = message.Split(',');
HZInterstitialAd.SetCallbackStateAndTag(displayStateParams[0], displayStateParams[1]);
HZInterstitialAd.SetCallbackStateAndPlacement(displayStateParams[0], displayStateParams[1]);
}

protected static void SetCallbackStateAndTag(string state, string tag) {
protected static void SetCallbackStateAndPlacement(string state, string placement) {
if (HZInterstitialAd.adDisplayListener != null) {
HZInterstitialAd.adDisplayListener(state, tag);
HZInterstitialAd.adDisplayListener(state, placement);
}
}

protected static IEnumerator InvokeCallbackNextFrame(string state, string tag) {
protected static IEnumerator InvokeCallbackNextFrame(string state, string placement) {
yield return null; // wait a frame
HZInterstitialAd.SetCallbackStateAndTag(state, tag);
HZInterstitialAd.SetCallbackStateAndPlacement(state, placement);
}
#endregion
}
Expand All @@ -203,11 +199,11 @@ protected static IEnumerator InvokeCallbackNextFrame(string state, string tag) {
#if UNITY_IPHONE && !UNITY_EDITOR
public class HZInterstitialAdIOS {
[DllImport ("__Internal")]
private static extern void hz_ads_show_interstitial(string tag);
private static extern void hz_ads_show_interstitial(string placement);
[DllImport ("__Internal")]
private static extern void hz_ads_fetch_interstitial(string tag);
private static extern void hz_ads_fetch_interstitial(string placement);
[DllImport ("__Internal")]
private static extern bool hz_ads_interstitial_is_available(string tag);
private static extern bool hz_ads_interstitial_is_available(string placement);
[DllImport ("__Internal")]
private static extern void hz_fetch_chartboost_for_location(string location);
[DllImport ("__Internal")]
Expand All @@ -217,15 +213,15 @@ public class HZInterstitialAdIOS {


public static void ShowWithOptions(HZShowOptions showOptions) {
hz_ads_show_interstitial(showOptions.Tag);
hz_ads_show_interstitial(showOptions.Placement);
}

public static void Fetch(string tag) {
hz_ads_fetch_interstitial(tag);
public static void Fetch(string placement) {
hz_ads_fetch_interstitial(placement);
}

public static bool IsAvailable(string tag) {
return hz_ads_interstitial_is_available(tag);
public static bool IsAvailable(string placement) {
return hz_ads_interstitial_is_available(placement);
}


Expand Down Expand Up @@ -253,25 +249,25 @@ public static void ShowWithOptions(HZShowOptions showOptions) {

AndroidJNIHelper.debug = false;
using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) {
jc.CallStatic("showInterstitial", showOptions.Tag);
jc.CallStatic("showInterstitial", showOptions.Placement);
}
}

public static void Fetch(string tag="default") {
public static void Fetch(string placement) {
if(Application.platform != RuntimePlatform.Android) return;

AndroidJNIHelper.debug = false;
using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) {
jc.CallStatic("fetchInterstitial", tag);
jc.CallStatic("fetchInterstitial", placement);
}
}

public static Boolean IsAvailable(string tag="default") {
public static Boolean IsAvailable(string placement) {
if(Application.platform != RuntimePlatform.Android) return false;

AndroidJNIHelper.debug = false;
using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) {
return jc.CallStatic<Boolean>("isInterstitialAvailable", tag);
return jc.CallStatic<Boolean>("isInterstitialAvailable", placement);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Plugins/Heyzap/HZInterstitialAd.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading