Merge branch 'main' of http://v4.9ms.co:7777/yufeng/SDK_UnityMoney
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EFSDK
|
||||
|
@ -10,8 +12,9 @@ namespace EFSDK
|
|||
public class EFSdk
|
||||
{
|
||||
private static EFSdk _mEfSdk;
|
||||
private static string mappingInfo = @"{""items"":[{""key"":""_sdk_float_balloon.png"",""value"":""aoa38ay.png""}]}";
|
||||
|
||||
|
||||
// 保持变量名不变
|
||||
private static string mappingInfo = "";
|
||||
|
||||
public static EFSdk get()
|
||||
{
|
||||
|
@ -28,18 +31,81 @@ namespace EFSDK
|
|||
|
||||
public EFSdk()
|
||||
{
|
||||
Debug.Log($"GetNewSDKClass():{GetNewSDKClass()}");
|
||||
|
||||
// java interface class
|
||||
using (AndroidJavaClass jc = new AndroidJavaClass("com.earn.push._SDK"))
|
||||
using (AndroidJavaClass jc = new AndroidJavaClass(GetNewSDKClass()))
|
||||
{
|
||||
jo = jc.GetStatic<AndroidJavaObject>("INSTANCE");
|
||||
}
|
||||
}
|
||||
|
||||
private static string oriSDKPName = "com.earn.push";
|
||||
private static string oriSDK = "_SDK";
|
||||
|
||||
private static string GetNewSDKClass()
|
||||
{
|
||||
return GetSDKPackage() + GenerateAndroidName(oriSDK);
|
||||
}
|
||||
|
||||
private static string GetSDKPackage()
|
||||
{
|
||||
string[] parts = oriSDKPName.Split('.');
|
||||
string[] parts2 = new string[parts.Length];
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
parts2[i] = GenerateAndroidName(parts[i]);
|
||||
}
|
||||
|
||||
string newPName = "";
|
||||
for (int i = 0; i < parts2.Length; i++)
|
||||
{
|
||||
newPName+=parts2[i]+".";
|
||||
}
|
||||
return newPName;
|
||||
}
|
||||
|
||||
private static string GenerateAndroidName(string oriString)
|
||||
{
|
||||
string md5Str = GetFirstEightWithUnderscore(GetMD5Hash(Application.identifier + oriString));
|
||||
return md5Str;
|
||||
}
|
||||
|
||||
public static string GetMD5Hash(string input)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
var inputBytes = Encoding.ASCII.GetBytes(input);
|
||||
var hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
foreach (var t in hashBytes)
|
||||
{
|
||||
builder.Append(t.ToString("x2")); // Convert byte to hexadecimal string
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
static string GetFirstEightWithUnderscore(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return str;
|
||||
string sub = str.Length <= 8 ? str : str.Substring(0, 8);
|
||||
if (char.IsDigit(sub[0]))
|
||||
{
|
||||
sub = "a" + sub;
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
|
||||
private T SDKCall<T>(string _method, params object[] _param)
|
||||
{
|
||||
try
|
||||
{
|
||||
return jo.Call<T>(_method, _param);
|
||||
string newMethod = GenerateAndroidName(_method);
|
||||
Debug.Log($"SDKCall<T> newMethod:{newMethod}");
|
||||
return jo.Call<T>(newMethod, _param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -53,7 +119,9 @@ namespace EFSDK
|
|||
{
|
||||
try
|
||||
{
|
||||
jo.Call(_method, _param);
|
||||
string newMethod = GenerateAndroidName(_method);
|
||||
Debug.Log($"SDKCall newMethod:{newMethod}");
|
||||
jo.Call(newMethod, _param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -63,11 +131,8 @@ namespace EFSDK
|
|||
|
||||
public enum ActionType
|
||||
{
|
||||
COIN_CLICK, //点击金币
|
||||
BALLOON_CLICK, //点击气球
|
||||
COIN_SHOW, //金币展示出来了
|
||||
BOX_SHOW, //气球/宝箱展示出来了
|
||||
GAM_LOAD_SUCC, //GAM页面加载成功
|
||||
SDK_INIT_Succ, //GAM页面加载成功
|
||||
H5_Load_Succ, //H5页面加载成功
|
||||
ON_RESUME, //游戏可见时回调,
|
||||
// CAN_GOBACK, //游戏可见时回调,
|
||||
}
|
||||
|
@ -111,8 +176,8 @@ namespace EFSDK
|
|||
|
||||
private void SDKInit()
|
||||
{
|
||||
// SDKCall("init");
|
||||
ActionCallback?.Invoke(ActionType.GAM_LOAD_SUCC, string.Empty);
|
||||
SDKCall("initSDK", mappingInfo);
|
||||
ActionCallback?.Invoke(ActionType.SDK_INIT_Succ, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -170,77 +235,6 @@ namespace EFSDK
|
|||
SDKCall("goHome");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否手动控制漂浮道具显示/隐藏
|
||||
/// SDK内默认当H5页面加载完成后自动显示漂浮道具
|
||||
/// </summary>
|
||||
/// <param name="autoShow">true: 自动显示/隐藏道具 false: 游戏主动控制道具显示/隐藏</param>
|
||||
/// <returns></returns>
|
||||
public void AutoShowFloat(bool autoShow)
|
||||
{
|
||||
SDKCall("autoShowFloat", autoShow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 飘金币
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public void ShowFloatCoin(int id)
|
||||
{
|
||||
SDKCall("showFloatCoin", id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 飘金币
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="res">悬浮金币按钮的图片资源,传字符串 0 或 1 0:金币图 1:红点宝箱图 </param>
|
||||
/// <returns></returns>
|
||||
public void ShowFloatCoin(int id, String res)
|
||||
{
|
||||
SDKCall("showFloatCoin", id, res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置悬浮金币按钮的图片资源
|
||||
/// </summary>
|
||||
/// <param name="res">传字符串 0 或 1 0:金币图 1:红点宝箱图</param>
|
||||
public void SetFloatCoinRes(String res)
|
||||
{
|
||||
SDKCall("setFloatCoinRes", res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏金币
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void HideFloatCoin()
|
||||
{
|
||||
SDKCall("hideFloatCoin");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 飘气球
|
||||
/// </summary>
|
||||
/// <param name="startId"></param>
|
||||
/// <param name="endId"></param>
|
||||
/// <param name="fly_first_time"></param>
|
||||
/// <param name="fly_gap_time"></param>
|
||||
/// <returns></returns>
|
||||
public void ShowBalloon(int startId, int endId, int fly_first_time, int fly_gap_time)
|
||||
{
|
||||
SDKCall("showBalloon", startId, endId, fly_first_time, fly_gap_time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏气球
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void HideBalloon()
|
||||
{
|
||||
SDKCall("hideBalloon");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -340,14 +334,6 @@ namespace EFSDK
|
|||
SDKCall("setGameName", gameName);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 设置推送 消息通知 的文案
|
||||
// /// </summary>
|
||||
// /// <param name="message"></param>
|
||||
// public void SetCommPushMessage(string message)
|
||||
// {
|
||||
// SDKCall("setCommPushMessage", message);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前游戏语言是否是 西班牙语
|
||||
|
|
|
@ -6,11 +6,7 @@ namespace EFSDK
|
|||
|
||||
public class EFSdkAndroid : MonoBehaviour
|
||||
{
|
||||
private string COIN_CLICK = "coin_click";
|
||||
private string BALLOON_CLICK = "balloon_click";
|
||||
private string Coin_Show = "Coin_Show";
|
||||
private string Box_Show = "Box_Show";
|
||||
private string Gam_Load_Succ = "Gam_Load_Succ";
|
||||
private string H5_Load_Succ = "Gam_Load_Succ";
|
||||
private string On_Resume = "onResume";
|
||||
private string Can_Goback = "canGoback";
|
||||
|
||||
|
@ -28,34 +24,11 @@ namespace EFSDK
|
|||
EFSdk.get().mCanGobackAction?.Invoke(bool.Parse(message.Split('#')[1]));
|
||||
}
|
||||
|
||||
if (BALLOON_CLICK.Equals(message))
|
||||
{
|
||||
//点击气球
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.BALLOON_CLICK, message);
|
||||
}
|
||||
|
||||
if (Coin_Show.Equals(message))
|
||||
{
|
||||
//金币展示出来了
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.COIN_SHOW, message);
|
||||
}
|
||||
if (COIN_CLICK.Equals(message))
|
||||
{
|
||||
//金币点击
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.COIN_CLICK, message);
|
||||
}
|
||||
|
||||
if (Box_Show.Equals(message))
|
||||
{
|
||||
//宝箱展示出来了
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.BOX_SHOW, message);
|
||||
}
|
||||
|
||||
if (message.Contains(Gam_Load_Succ))
|
||||
if (message.Contains(H5_Load_Succ))
|
||||
{
|
||||
//GAM页面加载成功 Gam_Load_Succ@id
|
||||
string[] parts = message.Split('@');
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.GAM_LOAD_SUCC, parts[1]);
|
||||
EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.H5_Load_Succ, parts[1]);
|
||||
}
|
||||
|
||||
if (message.StartsWith("reqNotifyPermission#"))
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using IOCompression = System.IO.Compression;
|
||||
|
||||
namespace EFSDK
|
||||
{
|
||||
public class AndroidResAarBuilder
|
||||
public class AndroidResAarBuilder
|
||||
{
|
||||
private static readonly string ResDir = "Assets/StreamingAssets/Android/res";
|
||||
private static readonly string ResDir = "Assets/StreamingAssets/Android";
|
||||
private static readonly string OutputDir = "Assets/Plugins/Android";
|
||||
private static readonly string TempDir = "Temp/AndroidResAar";
|
||||
private static readonly string EFSdk_FILE = "Assets/EFSDK/EFSdk.cs";
|
||||
|
@ -31,9 +33,9 @@ namespace EFSDK
|
|||
string manifestPath = Path.Combine(TempDir, "AndroidManifest.xml");
|
||||
File.WriteAllText(manifestPath,
|
||||
@"<manifest xmlns:android=""http://schemas.android.com/apk/res/android""
|
||||
package=""com.unity.reswrapper"">
|
||||
<application/>
|
||||
</manifest>");
|
||||
package=""com.unity.reswrapper"">
|
||||
<application/>
|
||||
</manifest>");
|
||||
|
||||
// 打包 AAR
|
||||
string aarPath = Path.Combine(OutputDir, "efsdk_res.aar");
|
||||
|
@ -50,10 +52,10 @@ namespace EFSDK
|
|||
string fileName = Path.GetFileName(kv.Key);
|
||||
simpleMapping[fileName] = kv.Value;
|
||||
}
|
||||
|
||||
|
||||
string mappingJson = GenerateMappingJson(mapping);
|
||||
// 更新 mappingInfo
|
||||
UpdateMappingInEFSdk_LineByLine(mappingJson);
|
||||
// UpdateMappingInEFSdk_LineByLine(mappingJson);
|
||||
// 映射文件
|
||||
string mappingPath = Path.Combine(TempDir, "res_mapping.json");
|
||||
File.WriteAllText(mappingPath, mappingJson);
|
||||
|
@ -66,30 +68,40 @@ namespace EFSDK
|
|||
private static void CopyAndRenameFiles(string srcDir, string dstDir, out Dictionary<string, string> mapping)
|
||||
{
|
||||
mapping = new Dictionary<string, string>();
|
||||
|
||||
foreach (var filePath in Directory.GetFiles(srcDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
if (filePath.EndsWith(".meta")) continue;
|
||||
|
||||
// 相对于源目录的路径
|
||||
string relativePath = filePath.Substring(srcDir.Length + 1).Replace("\\", "/");
|
||||
string newName = GenerateRandomAndroidName(Path.GetExtension(filePath));
|
||||
mapping[Path.GetFileName(filePath)] = newName;
|
||||
|
||||
string dstPath = Path.Combine(dstDir, newName);
|
||||
// 获取文件夹路径
|
||||
string relativeDir = Path.GetDirectoryName(relativePath).Replace("\\", "/");
|
||||
|
||||
// 生成随机文件名
|
||||
string newName = GenerateRandomAndroidName(filePath);
|
||||
|
||||
// 保存映射关系 (相对路径 + 原始文件名 -> 随机名)
|
||||
string key = Path.GetFileNameWithoutExtension(relativePath); // 可以保留目录信息
|
||||
string value = string.IsNullOrEmpty(relativeDir) ? newName : $"{relativeDir}/{newName}";
|
||||
string fileNameWithoutExt = Path.GetFileNameWithoutExtension(value);
|
||||
mapping[key] = fileNameWithoutExt;
|
||||
|
||||
// 目标路径
|
||||
string dstPath = Path.Combine(dstDir, value.Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
|
||||
// 确保目录存在
|
||||
string dstFolder = Path.GetDirectoryName(dstPath);
|
||||
if (!Directory.Exists(dstFolder)) Directory.CreateDirectory(dstFolder);
|
||||
|
||||
// 复制文件
|
||||
File.Copy(filePath, dstPath);
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
string relativeDir = dir.Substring(srcDir.Length + 1);
|
||||
string dstSubDir = Path.Combine(dstDir, relativeDir);
|
||||
if (!Directory.Exists(dstSubDir)) Directory.CreateDirectory(dstSubDir);
|
||||
}
|
||||
|
||||
Debug.Log("✅ Files copied and renamed");
|
||||
Debug.Log("✅ Files copied and renamed (directory structure preserved)");
|
||||
}
|
||||
|
||||
private static string GenerateMappingJson(Dictionary<string, string> mapping)
|
||||
{
|
||||
var items = new List<MappingItem>();
|
||||
|
@ -97,28 +109,56 @@ namespace EFSDK
|
|||
{
|
||||
items.Add(new MappingItem { key = kv.Key, value = kv.Value });
|
||||
}
|
||||
|
||||
MappingListWrapper wrapper = new MappingListWrapper { items = items };
|
||||
return JsonUtility.ToJson(wrapper, false);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private class MappingItem { public string key; public string value; }
|
||||
private class MappingItem
|
||||
{
|
||||
public string key;
|
||||
public string value;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private class MappingListWrapper { public List<MappingItem> items; }
|
||||
private static string GenerateRandomAndroidName(string ext)
|
||||
private class MappingListWrapper
|
||||
{
|
||||
int len = UnityEngine.Random.Range(6, 12);
|
||||
string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
string name = "";
|
||||
for (int i = 0; i < len; i++)
|
||||
public List<MappingItem> items;
|
||||
}
|
||||
|
||||
private static string GenerateRandomAndroidName(string filePath)
|
||||
{
|
||||
string ext = Path.GetExtension(filePath);
|
||||
string oriFileName = Path.GetFileNameWithoutExtension(filePath);
|
||||
string md5Str = GetFirstEightWithUnderscore(GetMD5Hash(Application.identifier + oriFileName+ oriFileName));
|
||||
return md5Str + ext;
|
||||
}
|
||||
static string GetFirstEightWithUnderscore(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return str;
|
||||
string sub = str.Length <= 8 ? str : str.Substring(0, 8);
|
||||
if (char.IsDigit(sub[0]))
|
||||
{
|
||||
name += chars[UnityEngine.Random.Range(0, chars.Length)];
|
||||
sub = "a" + sub;
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
public static string GetMD5Hash(string input)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
var inputBytes = Encoding.ASCII.GetBytes(input);
|
||||
var hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
if (!char.IsLetter(name[0])) name = "a" + name.Substring(1);
|
||||
var builder = new StringBuilder();
|
||||
foreach (var t in hashBytes)
|
||||
{
|
||||
builder.Append(t.ToString("x2")); // Convert byte to hexadecimal string
|
||||
}
|
||||
|
||||
return name + ext;
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateMappingInEFSdk_LineByLine(string mappingJson)
|
||||
|
@ -148,7 +188,8 @@ namespace EFSDK
|
|||
{
|
||||
if (lines[i].Contains("private static EFSdk _mEfSdk"))
|
||||
{
|
||||
lines[i] += $"\n private static string mappingInfo = @\"{mappingJson.Replace("\"", "\"\"")}\";";
|
||||
lines[i] +=
|
||||
$"\n private static string mappingInfo = @\"{mappingJson.Replace("\"", "\"\"")}\";";
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using EFSDK;
|
||||
using Unity.Plastic.Newtonsoft.Json.Linq;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
|
@ -18,12 +19,13 @@ public class DynamicApplicationClass : IPostGenerateGradleAndroidProject
|
|||
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
AndroidResAarBuilder.BuildAAR();
|
||||
var androidManifest = new SDKTool.AndroidManifest(SDKTool.GetManifestPath(path));
|
||||
androidManifest.SetStartingActivityAttribute("hardwareAccelerated", "true");
|
||||
androidManifest.Save();
|
||||
SetGradleConstraints(path);
|
||||
FixedAddressValueTypeAttribute(path);
|
||||
ParseConfigFile(path);
|
||||
// ParseConfigFile(path);
|
||||
}
|
||||
|
||||
private static void SetGradleConstraints(string path)
|
||||
|
@ -42,7 +44,8 @@ public class DynamicApplicationClass : IPostGenerateGradleAndroidProject
|
|||
if (line.Trim().Contains("com.earn.money:sdk"))
|
||||
{
|
||||
Debug.Log("找到com.earn.money:sdk");
|
||||
buildGradleOutLines.Add($" implementation ('com.earn.money:sdk:{SDKTool.GetSDKVersion()}')");
|
||||
|
||||
buildGradleOutLines.Add($" implementation ('com.earn.money:{Application.identifier}:{SDKTool.GetSDKVersion()}')");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -57,11 +57,11 @@ public class SDKTool
|
|||
public static string GetSDKVersion()
|
||||
{
|
||||
var xmlText =
|
||||
SDKEditorNetworkTool.GetText("https://repo.dgtverse.cn/repository/tk_my/com/earn/money/sdk/maven-metadata.xml");
|
||||
SDKEditorNetworkTool.GetText($"https://repo.dgtverse.cn/repository/tk_my/com/earn/money/{Application.identifier}/maven-metadata.xml");
|
||||
if (string.IsNullOrEmpty(xmlText))
|
||||
{
|
||||
throw new RuntimeBinderException(
|
||||
"获取版本号失败 , 接口请求返回为空,或请求不到. https://repo.dgtverse.cn/repository/tk_my/com/earn/money/sdk/maven-metadata.xml");
|
||||
$"获取版本号失败 , 接口请求返回为空,或请求不到. https://repo.dgtverse.cn/repository/tk_my/com/earn/money/{Application.identifier}/maven-metadata.xml");
|
||||
}
|
||||
|
||||
try
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
|
@ -19,7 +20,10 @@ namespace WZ
|
|||
|
||||
public static class IvRulesConst
|
||||
{
|
||||
public static int CurrentOverLevel = 0; //每跳过几次触发
|
||||
public static long CurrentInterval = 0; //广告最小时间间隔
|
||||
//每跳过几次触发
|
||||
public static Dictionary<string, int> OverLevels = new Dictionary<string, int>();
|
||||
|
||||
//广告最小时间间隔
|
||||
public static Dictionary<string, long> Intervals = new Dictionary<string, long>();
|
||||
}
|
||||
}
|
|
@ -10,8 +10,13 @@ public class AdjustManager : NormalSingleton<AdjustManager>
|
|||
private string appToken = "cap3ypurzegw"; // 替换为你的实际App Token
|
||||
private AdjustEnvironment environment = AdjustEnvironment.Sandbox; // 测试用Sandbox,发布用Production
|
||||
|
||||
private long startTime = 0;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
//开始计时
|
||||
startTime = TimeUtils.GetLocalTimestamp();
|
||||
|
||||
AdjustConfig config = new AdjustConfig(appToken, environment);
|
||||
|
||||
// 设置归因变更回调函数
|
||||
|
@ -25,6 +30,9 @@ public class AdjustManager : NormalSingleton<AdjustManager>
|
|||
|
||||
//计时3分钟
|
||||
AppSDKManager.Instance.Coroutine(AdjustNetwork.Instance.SetOrganic3Min());
|
||||
|
||||
ShuShuEvent.Instance.Track("adjust_init");
|
||||
FireBaseAnalyticsManager.Instance.LogEvent("adjust_init");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -36,7 +44,11 @@ public class AdjustManager : NormalSingleton<AdjustManager>
|
|||
Debug.Log("Attribution changed");
|
||||
AdjustNetwork.Instance.SetNetwork(attribution.Network);
|
||||
}
|
||||
|
||||
|
||||
public long GetStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
@ -22,6 +23,7 @@ public class AdjustNetwork : NormalSingleton<AdjustNetwork>
|
|||
string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
|
||||
if (string.IsNullOrEmpty(curNetwork))
|
||||
{
|
||||
LogEventGetSuccess();
|
||||
PlayerPrefs.SetString(KEY_USER_NETWORK, network);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
@ -47,7 +49,8 @@ public class AdjustNetwork : NormalSingleton<AdjustNetwork>
|
|||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
||||
LogEventGetSuccess();
|
||||
PlayerPrefs.SetString(KEY_USER_NETWORK, "Organic");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
@ -78,4 +81,23 @@ public class AdjustNetwork : NormalSingleton<AdjustNetwork>
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取adjust信息成功
|
||||
/// </summary>
|
||||
private void LogEventGetSuccess()
|
||||
{
|
||||
long startTime = AdjustManager.Instance.GetStartTime();
|
||||
long endTime = TimeUtils.GetLocalTimestamp();
|
||||
//计算两个时间相差多少秒
|
||||
// 计算毫秒差值的绝对值
|
||||
long diffMs = Math.Abs(startTime - endTime);
|
||||
// 转换为秒并向上取整
|
||||
double seconds = (double)diffMs / 1000;
|
||||
int time = (int)Math.Ceiling(seconds);
|
||||
|
||||
//数数
|
||||
ShuShuEvent.Instance.Track("adjust_get_success", "pass_time", time);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent("adjust_get_success", "pass_time", time);
|
||||
}
|
||||
}
|
|
@ -55,7 +55,6 @@ namespace WZ
|
|||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial);
|
||||
onAdLoaded?.Invoke(ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||
AdmobUtils.ParseResponseInfo(ad.GetResponseInfo()));
|
||||
|
||||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug(String.Format("[Admob] Interstitial ad paid {0} {1}.", adValue.Value, adValue.CurrencyCode));
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace WZ
|
|||
_adNetworks.Add(BigoAdsManager.Instance);
|
||||
_adNetworks.Add(TpnAdsManager.Instance);
|
||||
_adNetworks.Add(MaxAdsManager.Instance);
|
||||
|
||||
_adNetworks.Add(KwaiAdsManager.Instance);
|
||||
foreach (var network in _adNetworks)
|
||||
{
|
||||
network.RefreshAdsData();
|
||||
|
@ -91,7 +91,7 @@ namespace WZ
|
|||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
{
|
||||
|
||||
KwaiAdsManager.Instance.DisplayRewarded(_adPos,_rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -115,13 +115,12 @@ namespace WZ
|
|||
public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action<double> _closeCallback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, _adPos);
|
||||
if (!IsRewardAdReady())
|
||||
if (!IsInterstitialReady())
|
||||
{
|
||||
_closeCallback?.Invoke(0);
|
||||
_closeCallback = null;
|
||||
return;
|
||||
}
|
||||
otherAdsOnShow = true;
|
||||
PlatformType result = GetBestPlatformType(true);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial);
|
||||
if (result == PlatformType.AppLovin)
|
||||
|
@ -142,7 +141,7 @@ namespace WZ
|
|||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
{
|
||||
|
||||
KwaiAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -224,8 +223,7 @@ namespace WZ
|
|||
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
kwaiPrice: KwaiAdsManager.Instance.GetInterstitialRevenue(),
|
||||
toponAdUnitId: TpnAdsManager.Instance._topon_interstitial_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
|
@ -236,27 +234,15 @@ namespace WZ
|
|||
maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
kwaiPrice: KwaiAdsManager.Instance.GetRewardedRevenue(),
|
||||
toponAdUnitId: TpnAdsManager.Instance._topon_rewarded_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告看完回调
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback(double price)
|
||||
{
|
||||
AdRewardCallback?.Invoke(price);
|
||||
AdRewardCallback = null;
|
||||
}
|
||||
#region IvRules
|
||||
|
||||
/// <summary>
|
||||
/// 根据IvRules判断是否可以展示插屏
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IvRulesShow(IvType ivadType)
|
||||
{
|
||||
//1.获取远程配置
|
||||
|
@ -286,36 +272,51 @@ namespace WZ
|
|||
}
|
||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||
int skipLevel = ivRulesData.skipLevel;
|
||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0);
|
||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 0);
|
||||
if (currentSkipLevel < skipLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
||||
LoggerUtils.Debug($"[SDK] {ivadType} skipLevel limit");
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1);
|
||||
return false;
|
||||
}
|
||||
//5.判断overLevel(没跳过几次触发)
|
||||
//5.判断overLevel(每跳过几次触发)
|
||||
int overLevel = ivRulesData.overLevel;
|
||||
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
||||
int currentOverLevel = IvRulesConst.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0;
|
||||
if (currentOverLevel < overLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] overLevel limit");
|
||||
IvRulesConst.CurrentOverLevel++;
|
||||
LoggerUtils.Debug($"[SDK] {ivadType} overLevel limit");
|
||||
IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
//6.判断interval(广告时间间隔)
|
||||
int interval = ivRulesData.interval;
|
||||
long currentInterval = IvRulesConst.CurrentInterval;
|
||||
long currentInterval = IvRulesConst.Intervals.ContainsKey(ivadType.ToString()) ? IvRulesConst.Intervals[ivadType.ToString()] : 0;
|
||||
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||
|
||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] interval limit");
|
||||
LoggerUtils.Debug($"[SDK] {ivadType} interval limit");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 看激励广告之后调用
|
||||
/// </summary>
|
||||
public void ClearIvRules()
|
||||
{
|
||||
var localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||
foreach (var key in IvRulesConst.Intervals.Keys.ToList())
|
||||
{
|
||||
IvRulesConst.Intervals[key] = localTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 检查并刷新过期竞价
|
||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
||||
|
@ -436,12 +437,10 @@ namespace WZ
|
|||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
// todo: 刷新激励广告
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
// todo: 刷新插屏广告
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WZ
|
|||
Banner,
|
||||
Native,
|
||||
Splash,
|
||||
Fix,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ namespace WZ
|
|||
{
|
||||
public void OnSuccess()
|
||||
{
|
||||
Debug.Log("快手广告初始化成功");
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
Debug.Log("[kwai] 快手广告初始化成功");
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"快手广告初始化失败 code is {code}, msg:{msg}");
|
||||
LoggerUtils.Debug($"[kwai] 快手广告初始化失败 code is {code}, msg:{msg}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,27 +7,50 @@ namespace WZ
|
|||
public void OnAdClick()
|
||||
{
|
||||
// 插页广告调整转换页 | Interstitial ad agjust conversion page
|
||||
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._interstitialAdUnitId,
|
||||
AdsType.Interstitial,
|
||||
"",
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
|
||||
LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdClick");
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 插页广告关闭 | Interstitial ad close
|
||||
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._interstitialAdUnitId,
|
||||
AdsType.Interstitial,
|
||||
"",
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
KwaiAdsManager.Instance._ivCloseCallback?.Invoke(KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
KwaiAdsManager.Instance._ivCloseCallback = null;
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdClose");
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 插页视频播放完成 | Interstitial video play complete
|
||||
KwaiAdsManager.Instance.OnInterstitialCallback();
|
||||
LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 插页视频曝光 | Interstitial video show
|
||||
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial);
|
||||
LoggerUtils.Debug("[kwai] InterstitialAdListener#OnAdShow");
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogError($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
KwaiAdsManager.Instance._ivCloseCallback?.Invoke(0);
|
||||
KwaiAdsManager.Instance._ivCloseCallback = null;
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
AdsActionEvents.TrackAdFailToShow(KwaiAdsManager.Instance.Platfrom,AdsType.Interstitial,msg,"");
|
||||
LoggerUtils.Debug($"[kwai] RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -6,34 +7,39 @@ namespace WZ
|
|||
{
|
||||
public class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
KwaiAdsManager.Instance._interRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, KwaiAdsManager.Instance._interRetryAttempt));
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay,
|
||||
KwaiAdsManager.Instance.LoadInterstitial);
|
||||
AdsActionEvents.TrackAdFailToLoad(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Interstitial,
|
||||
Time.realtimeSinceStartup - KwaiAdsManager.Instance._ivStartLoadTime,
|
||||
msg);
|
||||
|
||||
LoggerUtils.Debug($"[kwai] InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
LoggerUtils.Debug($"[kwai] InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
{
|
||||
KwaiAdsManager.Instance.interstitiaAdRevenue = result;
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
}
|
||||
LoggerUtils.Debug($"[kwai] InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial);
|
||||
KwaiAdsManager.Instance._interRetryAttempt = 0;
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue = DataUtils.StringToDouble(price);
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Interstitial,
|
||||
Time.realtimeSinceStartup - KwaiAdsManager.Instance._ivStartLoadTime);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,128 +1,202 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public class KwaiAdsManager : NormalSingleton<KwaiAdsManager>
|
||||
public class KwaiAdsManager : NormalSingleton<KwaiAdsManager>, IAdService
|
||||
{
|
||||
//目前都是测试id
|
||||
private const string appId = "899999";
|
||||
private const string token = "EaCw0AipSYyvf3E7";
|
||||
private const string rewardAdUnitId = "8999996001";
|
||||
private const string interstitialAdUnitId = "8999996002";
|
||||
private string _appId = "";
|
||||
private string _token = "";
|
||||
public string _rewardAdUnitId = "";
|
||||
public string _interstitialAdUnitId = "";
|
||||
public double _rewardAdRevenue = 0;
|
||||
public double _interstitiaAdRevenue = 0;
|
||||
private IRewardAdController _rewardAdController;
|
||||
private IInterstitialAdController _interstitialAdController;
|
||||
public string _rvPos;
|
||||
public string _ivPos;
|
||||
public Action<bool, double> _rvCloseCallback = null;
|
||||
public Action<double> _ivCloseCallback = null;
|
||||
public Action _rvShowFailedCallback = null;
|
||||
public int _rewardRetryAttempt;
|
||||
public int _interRetryAttempt;
|
||||
public float _rvStartLoadTime = 0;
|
||||
public float _ivStartLoadTime = 0;
|
||||
public string ClientName => "Kwai";
|
||||
|
||||
/// <summary>
|
||||
/// 目前是千倍广告价值
|
||||
/// </summary>
|
||||
public double rewardAdRevenue = 0;
|
||||
/// <summary>
|
||||
/// 插屏奖励价值 如果有竞价功能可能会用到
|
||||
/// </summary>
|
||||
public double interstitiaAdRevenue = 0;
|
||||
public PlatformType Platfrom => PlatformType.Kwai;
|
||||
|
||||
private IRewardAdController rewardAdController;
|
||||
private IInterstitialAdController interstitialAdController;
|
||||
|
||||
public void Init()
|
||||
public void Initialize()
|
||||
{
|
||||
bool debug = true; // Whether in debug mode. Plsease set to false when in release build.
|
||||
if (string.IsNullOrEmpty(_appId) || string.IsNullOrEmpty(_token)) return;
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId)
|
||||
.SetToken(token)
|
||||
.SetAppName("App Name") // Optional
|
||||
.SetDebugLog(debug) // Optional
|
||||
.SetAppId(_appId)
|
||||
.SetToken(_token)
|
||||
.SetDebugLog(false)
|
||||
.Build();
|
||||
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl());
|
||||
}
|
||||
|
||||
#region 激励广告
|
||||
|
||||
/// <summary>
|
||||
/// 加载激励广告
|
||||
/// </summary>
|
||||
public void LoadRewardAd()
|
||||
public void RefreshAdsData()
|
||||
{
|
||||
if (rewardAdController != null)
|
||||
{
|
||||
rewardAdController.Destroy();
|
||||
rewardAdController = null;
|
||||
rewardAdRevenue = 0;
|
||||
}
|
||||
|
||||
rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(rewardAdUnitId);
|
||||
rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener());
|
||||
_appId = AdConfigParser.GetKwaiAppId();
|
||||
_token = AdConfigParser.GetKwaiAppToken();
|
||||
_rewardAdUnitId = AdConfigParser.GetKwaiAdUnits(AdsType.Rewarded).FirstOrDefault();
|
||||
_interstitialAdUnitId = AdConfigParser.GetKwaiAdUnits(AdsType.Interstitial).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
public void ShowRewardAd()
|
||||
|
||||
#region 激励广告
|
||||
public void LoadRewarded()
|
||||
{
|
||||
if (rewardAdController != null)
|
||||
if (string.IsNullOrEmpty(_rewardAdUnitId)) return;
|
||||
if (_rewardAdController != null)
|
||||
{
|
||||
rewardAdController.Show();
|
||||
_rewardAdController.Destroy();
|
||||
_rewardAdController = null;
|
||||
_rewardAdRevenue = 0;
|
||||
}
|
||||
|
||||
_rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_rewardAdUnitId);
|
||||
_rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener());
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, "", "", AdsType.Rewarded);
|
||||
_ivStartLoadTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
public bool IsRewardedAvailable()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_rewardAdUnitId)) return false;
|
||||
return _rewardAdController != null && _rewardAdController.IsReady();
|
||||
}
|
||||
|
||||
public void DisplayRewarded(string _adPos, Action<bool, double> _rewardCallback = null, Action _showFailedCallback = null)
|
||||
{
|
||||
_adPos = _rvPos;
|
||||
_rvCloseCallback = _rewardCallback;
|
||||
_rvShowFailedCallback = _showFailedCallback;
|
||||
if (_rewardAdController != null)
|
||||
{
|
||||
_rewardAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadRewardAd();
|
||||
_showFailedCallback?.Invoke();
|
||||
LoadRewarded();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback()
|
||||
public double GetRewardedRevenue()
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(rewardAdRevenue);
|
||||
LoadRewardAd();
|
||||
return _rewardAdRevenue;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 插屏
|
||||
public void LoadInterstitial()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interstitialAdUnitId)) return;
|
||||
if (_interstitialAdController != null)
|
||||
{
|
||||
_interstitialAdController.Destroy();
|
||||
_interstitialAdController = null;
|
||||
_interstitiaAdRevenue = 0;
|
||||
}
|
||||
|
||||
_interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(_interstitialAdUnitId);
|
||||
_interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener());
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, "", "", AdsType.Interstitial);
|
||||
_ivStartLoadTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
public bool IsInterstitialAvailable()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interstitialAdUnitId)) return false;
|
||||
return _interstitialAdController != null && _interstitialAdController.IsReady();
|
||||
}
|
||||
|
||||
public void DisplayInterstitial(string _adPos, IvType _IvType = IvType.IV1, Action<double> _closeCallback = null)
|
||||
{
|
||||
_ivCloseCallback = _closeCallback;
|
||||
if (_interstitialAdController != null)
|
||||
{
|
||||
_interstitialAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_closeCallback?.Invoke(0);
|
||||
LoadInterstitial();
|
||||
}
|
||||
}
|
||||
|
||||
public double GetInterstitialRevenue()
|
||||
{
|
||||
return _interstitiaAdRevenue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 插屏
|
||||
#region 横幅广告功能
|
||||
public void LoadBanner() { }
|
||||
public bool IsBannerAvailable() { return false; }
|
||||
public void DisplayBanner() { }
|
||||
public void HideBanner() { }
|
||||
public double GetBannerRevenue() { return 0; }
|
||||
#endregion
|
||||
|
||||
public void LoadInterstitialAd()
|
||||
#region 开屏广告功能
|
||||
public void LoadSplash() { }
|
||||
public bool IsSplashAvailable() { return false; }
|
||||
public void DisplaySplash() { }
|
||||
public double GetSplashRevenue() { return 0; }
|
||||
#endregion
|
||||
|
||||
#region 原生广告功能
|
||||
public void LoadNative() { }
|
||||
public bool IsNativeAvailable(string adUnitId) { return false; }
|
||||
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position) { }
|
||||
public void RemoveNative(string adUnitId) { }
|
||||
public double GetNativeRevenue(string adUnitId) { return 0; }
|
||||
#endregion
|
||||
|
||||
#region 收益上报
|
||||
public void TrackAdImpression(AdsType type)
|
||||
{
|
||||
if (interstitialAdController != null)
|
||||
{
|
||||
interstitialAdController.Destroy();
|
||||
interstitialAdController = null;
|
||||
interstitiaAdRevenue = 0;
|
||||
}
|
||||
AdjustTrackEvent.Instance.TrackAdEvent(type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
|
||||
ClientName,
|
||||
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId,
|
||||
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId);
|
||||
|
||||
interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(interstitialAdUnitId);
|
||||
interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener());
|
||||
}
|
||||
FireBaseAnalyticsManager.Instance.OnAdRevenueEvent(ClientName,
|
||||
ClientName,
|
||||
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId,
|
||||
type,
|
||||
type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
AdPlayCountManager.GetAdPlayCount(type));
|
||||
|
||||
public void ShowInterstitialAd()
|
||||
{
|
||||
if (interstitialAdController != null)
|
||||
{
|
||||
interstitialAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadInterstitialAd();
|
||||
}
|
||||
}
|
||||
ShuShuEvent.Instance.OnAdRevenueEvent(ClientName,
|
||||
ClientName,
|
||||
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId,
|
||||
type.ToString(),
|
||||
type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
AdPlayCountManager.GetAdPlayCount(type));
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnInterstitialCallback()
|
||||
{
|
||||
if (AdsSDKManager.Instance.IsMoreAdsBidding)
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(interstitiaAdRevenue);
|
||||
}
|
||||
|
||||
LoadInterstitialAd();
|
||||
AdsActionEvents.TrackAdImpression(Platfrom,
|
||||
ClientName,
|
||||
type == AdsType.Rewarded ? _rewardAdUnitId : _interstitialAdUnitId,
|
||||
type,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
type == AdsType.Rewarded ? _rewardAdRevenue : _interstitiaAdRevenue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -7,34 +7,56 @@ namespace WZ
|
|||
{
|
||||
public void OnAdClick()
|
||||
{
|
||||
// 激励广告调整转换页 | Reward ad adjustment conversion page
|
||||
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._rewardAdUnitId,
|
||||
AdsType.Rewarded,
|
||||
"",
|
||||
KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdClick");
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 激励广告关闭 | Reward ad close
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._rewardAdUnitId,
|
||||
AdsType.Rewarded,
|
||||
"",
|
||||
KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback?.Invoke(true, KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback = null;
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdClose");
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 激励视频播放完成 | Reward video play complete
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 激励视频曝光 | Reward video show
|
||||
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded);
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdShow");
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
KwaiAdsManager.Instance._rvShowFailedCallback?.Invoke();
|
||||
KwaiAdsManager.Instance._rvShowFailedCallback = null;
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
AdsActionEvents.TrackAdFailToShow(KwaiAdsManager.Instance.Platfrom,AdsType.Rewarded,msg,"");
|
||||
LoggerUtils.Debug($"[kwai] RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
// 获取到激励 | Reward earned
|
||||
KwaiAdsManager.Instance.OnRewardAdCallback();
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnRewardEarned");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -6,33 +7,38 @@ namespace WZ
|
|||
{
|
||||
public class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"RewardAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
LoggerUtils.Debug("[kwai] RewardAdLoadListener#OnAdLoadFailed , trackId:" + trackId);
|
||||
KwaiAdsManager.Instance._rewardRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, KwaiAdsManager.Instance._rewardRetryAttempt));
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay,
|
||||
KwaiAdsManager.Instance.LoadRewarded);
|
||||
AdsActionEvents.TrackAdFailToLoad(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Rewarded,
|
||||
Time.realtimeSinceStartup - KwaiAdsManager.Instance._rvStartLoadTime,
|
||||
msg);
|
||||
LoggerUtils.Debug("[kwai] RewardAdLoadListener#OnAdLoadFailed , retryDelay:" + trackId);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
LoggerUtils.Debug($"[kwai] RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
{
|
||||
KwaiAdsManager.Instance.rewardAdRevenue = result;
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
}
|
||||
LoggerUtils.Debug($"[kwai] RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded);
|
||||
KwaiAdsManager.Instance._rewardRetryAttempt = 0;
|
||||
KwaiAdsManager.Instance._rewardAdRevenue = DataUtils.StringToDouble(price);
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Rewarded,
|
||||
Time.realtimeSinceStartup - KwaiAdsManager.Instance._rvStartLoadTime);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -325,7 +325,7 @@ namespace WZ
|
|||
AdPlayCountManager.GetAdPlayCount(type));
|
||||
|
||||
AdsActionEvents.TrackAdImpression(Platfrom,
|
||||
adInfo.NetworkName,
|
||||
adInfo.NetworkName,
|
||||
adInfo.AdUnitIdentifier,
|
||||
type,
|
||||
type == AdsType.Rewarded ? _rvPos : "",
|
||||
|
|
|
@ -36,6 +36,20 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
|
||||
#region ad
|
||||
|
||||
/// <summary>
|
||||
/// 是否已缓存激励广告
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
||||
{
|
||||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||||
|
@ -45,12 +59,35 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
{
|
||||
if (isReward)
|
||||
{
|
||||
//callback?.Invoke();
|
||||
AdsSDKManager.Instance.ClearIvRules();
|
||||
callback?.Invoke(true, revenue);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(false, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已缓存插屏
|
||||
/// </summary>
|
||||
public bool IsInterstitialAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsInterstitialReady();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示插屏广告
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="ivadType"></param>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null)
|
||||
{
|
||||
//插屏展示逻辑
|
||||
|
@ -64,8 +101,9 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
|
||||
{
|
||||
//展示完一个插屏之后调用
|
||||
IvRulesConst.CurrentOverLevel = 0;
|
||||
IvRulesConst.CurrentInterval = TimeUtils.GetLocalTimestamp();
|
||||
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
|
||||
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
|
||||
callback?.Invoke(revenue);
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -79,10 +117,7 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -128,7 +163,6 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 在线参数
|
||||
|
||||
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
||||
|
@ -169,22 +203,24 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
#region EFSDK
|
||||
|
||||
/// <summary>
|
||||
/// 展示WebView
|
||||
/// </summary>
|
||||
/// <param name="id">标签id,存在多个WebView时,用于标识WebView</param>
|
||||
/// <param name="pos">广告位</param>
|
||||
/// <param name="url">网址</param>
|
||||
/// <param name="pRect">WebView展示区域的RectTransform</param>
|
||||
/// <param name="pCam">可不传;传值的话要传正交相机</param>
|
||||
public void ShowWebView(int id, string url, RectTransform pRect, Camera pCam = null)
|
||||
public void ShowWebView(int id, string pos, string url, RectTransform pRect, Camera pCam = null)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EFSdkManager.Instance.SetOkspinShowPos(pos);
|
||||
EFSdk.get().ShowWebView(id, url, pRect, pCam);
|
||||
}
|
||||
|
||||
|
@ -232,91 +268,8 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否手动控制漂浮道具显示/隐藏
|
||||
/// SDK内默认当H5页面加载完成后自动显示漂浮道具
|
||||
/// </summary>
|
||||
/// <param name="autoShow">true: 自动显示/隐藏道具 false: 游戏主动控制道具显示/隐藏</param>
|
||||
/// <returns></returns>
|
||||
public void AutoShowFloat(bool autoShow)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EFSdk.get().AutoShowFloat(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增接口飘金币
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="res">悬浮金币按钮的图片资源,传字符串 0 或 1 0:金币图 1:红点宝箱图 </param>
|
||||
/// <returns></returns>
|
||||
public void ShowFloatCoin(String res)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var remoteConfig = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("coin_position", 3);
|
||||
if (remoteConfig <= 0)
|
||||
{
|
||||
remoteConfig = 3;
|
||||
}
|
||||
if (remoteConfig > 10)
|
||||
{
|
||||
remoteConfig = 3;
|
||||
}
|
||||
EFSdk.get().SetFloatCoinRes(res);
|
||||
EFSdk.get().ShowFloatCoin(remoteConfig);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏金币
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void HideFloatCoin()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EFSdk.get().HideFloatCoin();
|
||||
}
|
||||
|
||||
/// <param name="startId">宝箱动画起始位置</param>
|
||||
/// <param name="endId">宝箱动画移动结束位置</param>
|
||||
/// <param name="fly_first_time">首次delay时间</param>
|
||||
/// <param name="fly_gap_time">每次漂浮移动的时间间隔</param>
|
||||
/// <returns></returns>
|
||||
public void ShowBalloon(int startId, int endId, int fly_first_time, int fly_gap_time)
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var startFlyIndex = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("start_fly", 40);
|
||||
var endFlyIndex = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("end_fly", 60);
|
||||
var flyFirstTime = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("fly_first_time", 3);
|
||||
var flyGapTime = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("fly_gap_time", 15);
|
||||
EFSdk.get().ShowBalloon(startFlyIndex, endFlyIndex, flyFirstTime, flyGapTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏气球
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void HideBalloon()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EFSdk.get().HideBalloon();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置推送开关, SDK默认关闭通知
|
||||
/// </summary>
|
||||
|
@ -575,4 +528,13 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 是否是自然量用户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool InOrganic()
|
||||
{
|
||||
return AdjustNetwork.Instance.InOrganic();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,32 +6,14 @@ namespace WZ
|
|||
{
|
||||
public class EFSdkManager : NormalSingleton<EFSdkManager>
|
||||
{
|
||||
private const string KEY_OKSPIN_SHOW_COUNT = "OKSPIN_SHOW_COUNT";
|
||||
|
||||
//互动广告位
|
||||
private string okspinShowPos = "";
|
||||
|
||||
public void Init()
|
||||
{
|
||||
EFSdk.get().Init((actionType, str) =>
|
||||
{
|
||||
if (EFSdk.ActionType.COIN_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击金币弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.BALLOON_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击宝箱弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.COIN_SHOW == actionType)
|
||||
{
|
||||
|
||||
}
|
||||
if (EFSdk.ActionType.BOX_SHOW == actionType)
|
||||
{
|
||||
|
||||
}
|
||||
if (EFSdk.ActionType.GAM_LOAD_SUCC == actionType)
|
||||
{
|
||||
// 标签id,标识哪个WebView加载成功了
|
||||
int id = int.Parse(str);
|
||||
}
|
||||
});
|
||||
EFSdk.get().Init((actionType, str) => { });
|
||||
|
||||
SetSDKEventCallback();
|
||||
SetHdH5ImpressionCallback();
|
||||
|
@ -54,17 +36,38 @@ namespace WZ
|
|||
{
|
||||
EFSdk.get().SetHdH5ImpressionCallback((url) =>
|
||||
{
|
||||
//TODO 判断是okspin还是appluck
|
||||
string h5ad_okspinrev = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("H5ad_okspinrev", "0");
|
||||
string h5ad_appluckrev= FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("H5ad_appluckrev", "0");
|
||||
//TODO 上报
|
||||
//判断链接不为空
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//判断链接是互动广告
|
||||
if (!url.Contains("gamifyspace"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//展示次数
|
||||
int count = PlayerPrefsUtils.GetPlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, 0);
|
||||
count++;
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count);
|
||||
|
||||
//互动广告只有okSpin
|
||||
float revenue = FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat("rev_okspin", 0);
|
||||
|
||||
//adjust
|
||||
//AdjustTrackEvent.Instance.TrackAdEvent();
|
||||
AdjustTrackEvent.Instance.TrackAdEvent(revenue, "H5ad_game", url, url);
|
||||
//firebase
|
||||
//FireBaseAnalyticsManager.Instance.OnAdRevenueEvent();
|
||||
FireBaseAnalyticsManager.Instance.OnAdRevenueEvent("H5ad_game", "H5ad_game", url, AdsType.Fix, revenue, okspinShowPos, count);
|
||||
//数数
|
||||
//ShuShuEvent.Instance.OnAdRevenueEvent();
|
||||
ShuShuEvent.Instance.OnAdRevenueEvent("H5ad_game", "H5ad_game", url, AdsType.Fix.ToString(), revenue, okspinShowPos, count);
|
||||
});
|
||||
}
|
||||
|
||||
public void SetOkspinShowPos(string pos)
|
||||
{
|
||||
okspinShowPos = pos;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,9 @@ namespace WZ
|
|||
AdConfigParser.Parse(GetRemoteConfigString("ad_config"));
|
||||
// 刷新广告位信息
|
||||
AdsSDKManager.Instance.RefreshAdsData();
|
||||
//AB测试分组参数
|
||||
GroupSet();
|
||||
|
||||
// adjust卸载监控
|
||||
|
||||
/* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */
|
||||
|
@ -37,6 +40,15 @@ namespace WZ
|
|||
// });
|
||||
}
|
||||
|
||||
private void GroupSet()
|
||||
{
|
||||
string value = GetRemoteConfigString("group_set");
|
||||
//数数
|
||||
ShuShuEvent.Instance.Track($"group_set_{value}");
|
||||
//firebase
|
||||
FireBaseAnalyticsManager.Instance.LogEvent($"group_set_{value}");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取int参数
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
{
|
||||
public static class DataUtils
|
||||
{
|
||||
[System.Serializable]
|
||||
|
@ -18,6 +19,20 @@ namespace WZ
|
|||
Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(wrappedJson);
|
||||
return wrapper.items;
|
||||
}
|
||||
|
||||
public static double StringToDouble(string str)
|
||||
{
|
||||
double result = 0;
|
||||
if (double.TryParse(str, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
||||
{
|
||||
Debug.Log("转换成功: " + result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("转换失败:字符串格式不正确");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa22f34439f14c8cbaa5fae4c4dc402b
|
||||
timeCreated: 1742203865
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f322db129aac4ea1aa9919e8c8f92a08
|
||||
timeCreated: 1756693458
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8af1d23b4bce430aa8bfb3e1b6b3b291
|
||||
timeCreated: 1756693481
|
After Width: | Height: | Size: 280 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 22d4b822110d1bd43932b2b737f61dce
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 9.4 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63a7e60d370bb1c48a1138e45315d8aa
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 9.4 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9cb4efb8034485741852541144c5a7a0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9934c44d94c1030438702e646cc1a5b1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9cfb6b46fea6c7845999842064fef0dd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 21 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0fa3d13d2c47b64c8a10c49839f888c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 22 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10def9eb660635b468ed7fc2277a4e6f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 89 KiB |
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2d7efc9e85a47e98bae42a19e1d52a3
|
||||
timeCreated: 1756693525
|