SDK_UnityMoney/Assets/Script/SDKManager/AdjustManager/AdjustNetwork.cs

81 lines
2.1 KiB
C#
Raw Normal View History

2025-08-31 05:48:26 +00:00
using System.Collections;
2025-09-01 10:32:50 +00:00
2025-08-31 03:55:05 +00:00
using UnityEngine;
2025-09-01 10:32:50 +00:00
using WZ;
2025-08-30 10:46:34 +00:00
2025-08-31 03:55:05 +00:00
public class AdjustNetwork : NormalSingleton<AdjustNetwork>
2025-08-30 10:46:34 +00:00
{
private const string KEY_USER_NETWORK = "KEY_USER_NETWORK";
2025-08-31 03:55:05 +00:00
public void SetNetwork(string network)
2025-08-30 10:46:34 +00:00
{
if (string.IsNullOrEmpty(network))
{
return;
}
2025-08-31 05:48:26 +00:00
if (network.ToLower().Replace(" ", "") == "Organic".ToLower().Replace(" ", ""))
{
return;
}
2025-08-30 10:46:34 +00:00
string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
if (string.IsNullOrEmpty(curNetwork))
{
PlayerPrefs.SetString(KEY_USER_NETWORK, network);
PlayerPrefs.Save();
}
}
2025-08-31 05:48:26 +00:00
/// <summary>
/// 3分钟设置自然量
/// </summary>
public IEnumerator SetOrganic3Min()
{
string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
if (!string.IsNullOrEmpty(curNetwork))
{
yield break;
}
//写死3分钟
yield return new WaitForSeconds(3 * 60);
//重新获取
curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
if (!string.IsNullOrEmpty(curNetwork))
{
yield break;
}
PlayerPrefs.SetString(KEY_USER_NETWORK, "Organic");
PlayerPrefs.Save();
}
2025-08-30 10:46:34 +00:00
/// <summary>
/// 是否是自然量用户
/// 默认买量用户
/// </summary>
/// <returns></returns>
2025-08-31 03:55:05 +00:00
public bool InOrganic()
2025-08-30 10:46:34 +00:00
{
string network = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
if (string.IsNullOrEmpty(network))
{
return true;
}
2025-08-30 11:16:32 +00:00
if (network.ToLower().Replace(" ", "") == "Organic".ToLower().Replace(" ", ""))
{
return true;
}
2025-08-30 10:46:34 +00:00
//去除大小写和空格之后再对比
if (network.ToLower().Replace(" ", "") == "Untrusted Devices".ToLower().Replace(" ", "") || network.ToLower().Replace(" ", "") == "Google Organic Search".ToLower().Replace(" ", ""))
{
return true;
}
return false;
}
}