Skip to content
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
2 changes: 1 addition & 1 deletion Assets/Plugins/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.unity" xmlns:tools="http://schemas.android.com/tools" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="27" />

<!-- Features -->
<uses-feature android:glEsVersion="0x00020000" />
Expand Down
22 changes: 22 additions & 0 deletions Assets/Plugins/Android/Heyzap/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.heyzap">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="15" />

<application>
<activity android:name="com.heyzap.sdk.ads.MediationTestActivity" />
<activity android:name="com.heyzap.sdk.ads.HeyzapProxyActivity" />
<activity android:name="com.heyzap.sdk.ads.VASTActivity" android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize" />
<activity android:name="com.heyzap.sdk.ads.HeyzapInterstitialActivity" android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize" />
<activity android:name="com.heyzap.sdk.ads.HeyzapVideoActivity" android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize" />
<receiver android:name="com.heyzap.sdk.ads.PackageAddedReceiver">
<intent-filter>
<data android:scheme="package" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>
</receiver>
</application>

</manifest>
9 changes: 9 additions & 0 deletions Assets/Plugins/Android/Heyzap/AndroidManifest.xml.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/HZBannerAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class HZBannerAd : MonoBehaviour {
public delegate void AdDisplayListener(string state, string tag);

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
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
6 changes: 1 addition & 5 deletions Assets/Plugins/Heyzap/HZIncentivizedAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class HZIncentivizedAd : MonoBehaviour {

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

//provided since JS can't use default parameters
/// <summary>
Expand All @@ -52,8 +52,6 @@ public static void Fetch() {
/// </summary>
/// <param name="tag">The ad tag to fetch an ad for.</param>
public static void Fetch(string tag) {
tag = HeyzapAds.TagForString(tag);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HZIncentivizedAdAndroid.Fetch(tag);
Expand Down Expand Up @@ -107,8 +105,6 @@ public static bool IsAvailable() {
/// </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);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
return HZIncentivizedAdAndroid.IsAvailable(tag);
Expand Down
10 changes: 3 additions & 7 deletions Assets/Plugins/Heyzap/HZInterstitialAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HZInterstitialAd : MonoBehaviour {

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

//provided since JS can't use default parameters
/// <summary>
Expand Down Expand Up @@ -80,8 +80,6 @@ public static void Fetch() {
/// </summary>
/// <param name="tag">The ad tag to fetch an ad for.</param>
public static void Fetch(string tag) {
tag = HeyzapAds.TagForString(tag);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HZInterstitialAdAndroid.Fetch(tag);
Expand All @@ -107,8 +105,6 @@ public static bool IsAvailable() {
/// </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);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
return HZInterstitialAdAndroid.IsAvailable(tag);
Expand Down Expand Up @@ -257,7 +253,7 @@ public static void ShowWithOptions(HZShowOptions showOptions) {
}
}

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

AndroidJNIHelper.debug = false;
Expand All @@ -266,7 +262,7 @@ public static void Fetch(string tag="default") {
}
}

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

AndroidJNIHelper.debug = false;
Expand Down
6 changes: 1 addition & 5 deletions Assets/Plugins/Heyzap/HZOfferwallAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class HZOfferWallAd : MonoBehaviour {
public delegate void VirtualCurrencyErrorListener(string errorMsg);
private static VirtualCurrencyErrorListener virtualCurrencyErrorListener;

private static HZOfferWallAd _instance = null;
private static HZOfferWallAd _instance;

//provided since JS can't use default parameters
/// <summary>
Expand Down Expand Up @@ -88,8 +88,6 @@ public static void Fetch() {
/// </summary>
/// <param name="tag">The ad tag to fetch an ad for.</param>
public static void Fetch(string tag) {
tag = HeyzapAds.TagForString(tag);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HZOfferWallAdAndroid.Fetch(tag);
Expand All @@ -115,8 +113,6 @@ public static bool IsAvailable() {
/// </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);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
return HZOfferWallAdAndroid.IsAvailable(tag);
Expand Down
15 changes: 4 additions & 11 deletions Assets/Plugins/Heyzap/HZShowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ namespace Heyzap {
public class HZShowOptions {

/// <summary>
/// An identifier for the location of the ad, which you can use to disable the ad from your dashboard. If not specified the tag "default" is always used.
/// Guaranteed to be non-null - will be set to the default value if the setter is called with `null`.
/// An identifier for the location of the ad, which you can use to disable the ad from your dashboard.
/// </summary>
/// <value>The tag.</value>
public string Tag {
get {
return tag;
}
set {
if (value != null) {
tag = value;
} else {
tag = HeyzapAds.DEFAULT_TAG;
}
tag = value;
}
}
private string tag = HeyzapAds.DEFAULT_TAG;
private string tag;
}

/// <summary>
Expand All @@ -36,7 +31,6 @@ public class HZIncentivizedShowOptions : HZShowOptions {
/// <summary>
/// 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`.
/// </summary>
public string IncentivizedInfo {
get {
Expand Down Expand Up @@ -96,7 +90,6 @@ public class HZOfferWallShowOptions : HZShowOptions {
/// <summary>
/// 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`.
/// </summary>
public bool ShouldCloseAfterFirstClick {
get {
Expand All @@ -108,4 +101,4 @@ public bool ShouldCloseAfterFirstClick {
}
private bool shouldCloseAfterFirstClick = HZOfferWallShowOptions.DEFAULT_SHOULD_CLOSE_AFTER_FIRST_CLICK;
}
}
}
6 changes: 1 addition & 5 deletions Assets/Plugins/Heyzap/HZVideoAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class HZVideoAd : MonoBehaviour {

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

//provided since JS can't use default parameters
/// <summary>
Expand Down Expand Up @@ -81,8 +81,6 @@ public static void Fetch() {
/// </summary>
/// <param name="tag">The ad tag to fetch an ad for.</param>
public static void Fetch(string tag) {
tag = HeyzapAds.TagForString(tag);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HZVideoAdAndroid.Fetch(tag);
Expand All @@ -108,8 +106,6 @@ public static bool IsAvailable() {
/// </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);

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
return HZVideoAdAndroid.IsAvailable(tag);
Expand Down
37 changes: 22 additions & 15 deletions Assets/Plugins/Heyzap/HeyzapAds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ namespace Heyzap {
/// Heyzap wrapper for iOS and Android via Unity. For more information, see https://developers.heyzap.com/docs/unity_sdk_setup_and_requirements .
/// </summary>
public class HeyzapAds : MonoBehaviour {
public const string Version = "9.51.0";
public delegate void NetworkCallbackListener(string network, string callback);

private static NetworkCallbackListener networkCallbackListener;
private static HeyzapAds _instance = null;
private static HeyzapAds _instance;

#region Flags for the call to HeyzapAds.StartWithOptions()
/// <summary>
Expand Down Expand Up @@ -77,8 +78,6 @@ public class HeyzapAds : MonoBehaviour {
/// </summary>
public const int FLAG_CHILD_DIRECTED_ADS = 1 << 6; // 64
#endregion

public const string DEFAULT_TAG = "default";

#region String constants to expect in Ad Listener & network callbacks
// `NetworkCallback` is a bit of a misnomer. The callback constants here are both for "network callbacks" and for ad listener callbacks. We should refactor these into two classes in the next major SDK.
Expand Down Expand Up @@ -140,8 +139,10 @@ public static class Network {
public static void Start(string publisher_id, int options) {
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
#if UNITY_ANDROID
HeyzapAdsAndroid.SetPluginVersion(Version);
HeyzapAdsAndroid.Start(publisher_id, options);
#elif UNITY_IPHONE
HeyzapAdsIOS.SetPluginVersion(Version);
HeyzapAdsIOS.Start(publisher_id, options);
#endif
#else
Expand Down Expand Up @@ -348,7 +349,7 @@ public static void HideDebugLogs() {
/// </summary>
public static void ShowThirdPartyDebugLogs() {
#if UNITY_IPHONE && !UNITY_EDITOR
HeyzapAdsIOS.ShowThirdPartyDebugLogs();
HeyzapAdsIOS.ShowThirdPartyDebugLogs();
#endif
}

Expand All @@ -358,7 +359,7 @@ public static void ShowThirdPartyDebugLogs() {
/// </summary>
public static void HideThirdPartyDebugLogs() {
#if UNITY_IPHONE && !UNITY_EDITOR
HeyzapAdsIOS.HideThirdPartyDebugLogs();
HeyzapAdsIOS.HideThirdPartyDebugLogs();
#endif
}

Expand All @@ -385,7 +386,7 @@ public static void SetBundleIdentifier(string bundleID) {
/// <param name="device_id">The Device ID that FAN prints to the iOS console</param>
public static void AddFacebookTestDevice(string device_id) {
#if UNITY_IPHONE && !UNITY_EDITOR
HeyzapAdsIOS.AddFacebookTestDevice(device_id);
HeyzapAdsIOS.AddFacebookTestDevice(device_id);
#endif
}
#endregion
Expand All @@ -402,22 +403,14 @@ protected static void SetNetworkCallback(string network, string callback) {
}
}

public static void InitReceiver(){
public static void InitReceiver() {
if (_instance == null) {
GameObject receiverObject = new GameObject("HeyzapAds");
DontDestroyOnLoad(receiverObject);
_instance = receiverObject.AddComponent<HeyzapAds>();
}
}

public static string TagForString(string tag) {
if (tag == null) {
tag = HeyzapAds.DEFAULT_TAG;
}

return tag;
}

// Within Unity's .NET framework we don't have a stock solution for converting objets to Json so we need to implement a custom solution
static private string GetGdprConsentDataAsJsonString(Dictionary<string, string> gdprConsentData)
{
Expand All @@ -433,6 +426,8 @@ static private string GetGdprConsentDataAsJsonString(Dictionary<string, string>
#if UNITY_IPHONE && !UNITY_EDITOR
public class HeyzapAdsIOS : MonoBehaviour
{
[DllImport ("__Internal")]
private static extern void hz_ads_set_plugin_version(string pluginVersion);

[DllImport ("__Internal")]
private static extern void hz_ads_start_app(string publisher_id, int flags);
Expand Down Expand Up @@ -479,6 +474,10 @@ public class HeyzapAdsIOS : MonoBehaviour
[DllImport ("__Internal")]
private static extern void hz_add_facebook_test_device(string device_id);

public static void SetPluginVersion(string pluginVersion) {
hz_ads_set_plugin_version(pluginVersion);
}

public static void Start(string publisher_id, int options=0) {
hz_ads_start_app(publisher_id, options);
}
Expand Down Expand Up @@ -548,6 +547,14 @@ public static void AddFacebookTestDevice(string device_id) {
#if UNITY_ANDROID && !UNITY_EDITOR
public class HeyzapAdsAndroid : MonoBehaviour
{
public static void SetPluginVersion(string pluginVersion) {
if (Application.platform != RuntimePlatform.Android) return;
AndroidJNIHelper.debug = false;
using (AndroidJavaClass jc = new AndroidJavaClass("com.heyzap.sdk.extensions.unity3d.UnityHelper")) {
jc.CallStatic("addCustomParameter", "plugin_version", pluginVersion);
}
}

public static void Start(string publisher_id, int options=0) {
if(Application.platform != RuntimePlatform.Android) return;

Expand Down
Loading