update: 添加 Android 设备获取信息 TryCatch 块
Signed-off-by: huyufei <yufei.hu@castbox.fm>deeplink
parent
7867db4655
commit
e2c3b5bc7c
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -34,23 +35,29 @@ namespace Guru
|
||||||
private static void GetIOSDeviceInfo()
|
private static void GetIOSDeviceInfo()
|
||||||
{
|
{
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
string content = iOSDeviceInfo();
|
try
|
||||||
Debug.Log($"GetDeviceInfo:{content}");
|
|
||||||
if(!string.IsNullOrEmpty(content))
|
|
||||||
{
|
{
|
||||||
string[] infos = content.Split('$');
|
Debug.Log($"[SDK] --- GetIOSDeviceInfo:: iOSDeviceInfo<string>");
|
||||||
IPMConfig.SetDeviceId(infos[0]);
|
string content = iOSDeviceInfo();
|
||||||
IPMConfig.IPM_APP_VERSION = infos[1];
|
Debug.Log($"GetDeviceInfo:{content}");
|
||||||
IPMConfig.IPM_TIMEZONE = infos[2];
|
if(!string.IsNullOrEmpty(content))
|
||||||
IPMConfig.IPM_MODEL = infos[3];
|
{
|
||||||
IPMConfig.IPM_LANGUAGE = infos[4];
|
string[] infos = content.Split('$');
|
||||||
IPMConfig.IPM_LOCALE = infos[5];
|
IPMConfig.SetDeviceId(infos[0]);
|
||||||
IPMConfig.IPM_COUNTRY_CODE = infos[6];
|
IPMConfig.IPM_APP_VERSION = infos[1];
|
||||||
IsGetDeviceInfoSuccess = true;
|
IPMConfig.IPM_TIMEZONE = infos[2];
|
||||||
|
IPMConfig.IPM_MODEL = infos[3];
|
||||||
|
IPMConfig.IPM_LANGUAGE = infos[4];
|
||||||
|
IPMConfig.IPM_LOCALE = infos[5];
|
||||||
|
IPMConfig.IPM_COUNTRY_CODE = infos[6];
|
||||||
|
IsGetDeviceInfoSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError(ex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetiOSBadge()
|
public static void SetiOSBadge()
|
||||||
|
|
@ -82,23 +89,31 @@ namespace Guru
|
||||||
private static void GetAndroidDeviceInfo()
|
private static void GetAndroidDeviceInfo()
|
||||||
{
|
{
|
||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
_androidJavaObject ??= new AndroidJavaObject("com.guru.u3d2android.u3d2android");
|
try
|
||||||
if (_androidJavaObject != null)
|
{
|
||||||
{
|
_androidJavaObject ??= new AndroidJavaObject("com.guru.u3d2android.u3d2android");
|
||||||
string content = _androidJavaObject.Call<string>("getDeviceInfo");
|
if (_androidJavaObject != null)
|
||||||
Debug.Log($"GetDeviceInfo:{content}");
|
{
|
||||||
if(!string.IsNullOrEmpty(content))
|
Debug.Log($"[SDK] --- GetAndroidDeviceInfo:: com.guru.u3d2android.u3d2android: getDeviceInfo<string>");
|
||||||
{
|
string content = _androidJavaObject.Call<string>("getDeviceInfo");
|
||||||
string[] infos = content.Split('$');
|
Debug.Log($"GetDeviceInfo:{content}");
|
||||||
IPMConfig.IPM_BRAND = infos[0];
|
if(!string.IsNullOrEmpty(content))
|
||||||
IPMConfig.IPM_LANGUAGE = infos[1];
|
{
|
||||||
IPMConfig.IPM_MODEL = infos[2];
|
string[] infos = content.Split('$');
|
||||||
IPMConfig.IPM_TIMEZONE = infos[4];
|
IPMConfig.IPM_BRAND = infos[0];
|
||||||
IPMConfig.IPM_LOCALE = infos[5];
|
IPMConfig.IPM_LANGUAGE = infos[1];
|
||||||
IPMConfig.IPM_COUNTRY_CODE = infos[6];
|
IPMConfig.IPM_MODEL = infos[2];
|
||||||
IsGetDeviceInfoSuccess = true;
|
IPMConfig.IPM_TIMEZONE = infos[4];
|
||||||
}
|
IPMConfig.IPM_LOCALE = infos[5];
|
||||||
}
|
IPMConfig.IPM_COUNTRY_CODE = infos[6];
|
||||||
|
IsGetDeviceInfoSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError(ex);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue