diff --git a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
index d9ddfe0..143c39f 100644
--- a/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
+++ b/Runtime/GuruCore/Runtime/Analytics/Analytics.cs
@@ -162,7 +162,7 @@ namespace Guru
}
///
- /// Firebase上报用户属性
+ /// 设置用户属性
///
public static void SetUserProperty(string key, string value)
{
diff --git a/Runtime/GuruNetworkMonitor/Runtime/NetworkStatusMonitor.cs b/Runtime/GuruNetworkMonitor/Runtime/NetworkStatusMonitor.cs
index b2236b9..96353bd 100644
--- a/Runtime/GuruNetworkMonitor/Runtime/NetworkStatusMonitor.cs
+++ b/Runtime/GuruNetworkMonitor/Runtime/NetworkStatusMonitor.cs
@@ -1,10 +1,8 @@
namespace Guru.Network
{
-
+ using Guru;
using System;
- using System.Collections.Generic;
- using System.Linq;
using UnityEngine;
public class NetworkStatusMonitor
@@ -19,98 +17,21 @@ namespace Guru.Network
private const string NETWORK_STATUS_BLUETOOTH = "bluetooth";
private const string NETWORK_STATUS_OTHER = "other";
- private bool _isReady = false;
-
- private INetworkStatusProxy _proxy;
- private INetworkStatusProxy Proxy
- {
- get
- {
- if (_proxy == null)
- {
-#if UNITY_EDITOR
- _proxy = new NetworkStatusEditor();
-#elif UNITY_ANDROID
- _proxy = new NetworkStatusAndroid();
-#elif UNITY_IOS
- _proxy = new NetworkStatusIOS();
-#endif
- }
-
- if (_proxy == null)
- {
- // 如果未实现则报异常
- throw new NotImplementedException("Can't find NetworkStatusProxy instance!!");
- }
-
- return _proxy;
- }
-
- }
-
- ///
- /// 网络状态列表
- ///
- private List _statusNameList = new List()
- {
- NETWORK_STATUS_VPN,
- NETWORK_STATUS_TETHER,
- NETWORK_STATUS_MOBILE,
- NETWORK_STATUS_WIFI,
- NETWORK_STATUS_ETHERNET,
- NETWORK_STATUS_BLUETOOTH,
- NETWORK_STATUS_OTHER,
- NETWORK_STATUS_NONE,
- };
-
- public void Init(Action onInitComplete = null)
- {
- Proxy.Init(success =>
- {
- _isReady = success;
- onInitComplete?.Invoke(success);
- });
- }
-
///
/// 获取网络状态
///
///
public string GetNetworkStatus()
{
- if (_isReady)
+ switch (Application.internetReachability)
{
- var status = Proxy.GetNetworkStatus();
- if (status != null && status.Length > 0)
- {
- string statusName = "";
- for (int i = 0; i < _statusNameList.Count; i++)
- {
- // 根据名称优先级, 先获取到的优先上报
- statusName = _statusNameList[i];
- if (status.Contains(statusName))
- {
- Debug.Log($"{Tag} --- GetNetworkStatus: [{string.Join(",", status)}]");
- return statusName;
- }
- }
- }
+ case NetworkReachability.ReachableViaLocalAreaNetwork:
+ return NETWORK_STATUS_WIFI;
+ case NetworkReachability.ReachableViaCarrierDataNetwork:
+ return NETWORK_STATUS_MOBILE;
}
- Debug.LogWarning($"{Tag} --- Network Monitor is not ready!");
return NETWORK_STATUS_NONE;
}
-
- // private void OnProxyInitComplete(bool success)
- // {
- // if (success)
- // {
- // Debug.Log($"{Tag} --- NetworkStatusMonitor init success");
- // }
- // else
- // {
- // Debug.LogError($"{Tag} --- NetworkStatusMonitor init failed");
- // }
- // }
}
}
\ No newline at end of file