update: 完善 IOS ATT 打点和流程
parent
d26cc45962
commit
a009a220e4
|
|
@ -29,11 +29,20 @@ namespace Guru
|
|||
/// 使用自定义的Consent, 获取用户授权后, 调用此方法
|
||||
/// </summary>
|
||||
/// <param name="userAllow"></param>
|
||||
public static void StartAdsWithCustomConsent(bool userAllow = true)
|
||||
/// <param name="guideType">Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max </param>
|
||||
public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom")
|
||||
{
|
||||
#if UNITY_IOS
|
||||
_attType = guideType;
|
||||
InitAttStatus();
|
||||
#endif
|
||||
if (userAllow)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
CheckAttStatus();
|
||||
#else
|
||||
StartAdService();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -56,6 +65,9 @@ namespace Guru
|
|||
|
||||
private void OnConsentOver(int code)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
InitAttStatus();
|
||||
#endif
|
||||
Callbacks.ConsentFlow._onConsentResult?.Invoke(code);
|
||||
switch(code)
|
||||
{
|
||||
|
|
@ -63,7 +75,7 @@ namespace Guru
|
|||
case GuruConsent.StatusCode.NOT_AVAILABLE:
|
||||
// 已获取授权, 或者地区不可用
|
||||
#if UNITY_IOS
|
||||
CheckATTStatus();
|
||||
CheckAttStatus();
|
||||
#else
|
||||
StartAdService();
|
||||
#endif
|
||||
|
|
@ -71,17 +83,69 @@ namespace Guru
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IOS ATT 广告授权流程
|
||||
|
||||
#if UNITY_IOS
|
||||
|
||||
private static string _initialAttStatus;
|
||||
private static String _attType = "admob";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示系统的 ATT 弹窗
|
||||
/// </summary>
|
||||
public static void RequestAttDialog()
|
||||
{
|
||||
LogI($"RequestATTDialog");
|
||||
ATTManager.RequestATTDailog(ReportAttStatus);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 ATT 状态
|
||||
/// </summary>
|
||||
public static void InitAttStatus()
|
||||
{
|
||||
_initialAttStatus = ATTManager.GetStatus();
|
||||
SetUserProperty(Analytics.ParameterATTStatus, _initialAttStatus); // 上报一个初始的状态
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// iOS 平台检查 ATT 状态
|
||||
/// </summary>
|
||||
private void CheckATTStatus()
|
||||
private static void CheckAttStatus() => ATTManager.CheckStatus(ReportAttStatus);
|
||||
|
||||
private static void ReportAttStatus(string status)
|
||||
{
|
||||
AttManager.Instance.CheckATTStatus(OnATTStatus);
|
||||
LogI($"{Tag} --- Get Att status: {status}");
|
||||
SetUserProperty(Analytics.ParameterATTStatus, status); // 当前的状态
|
||||
if (!string.IsNullOrEmpty(_initialAttStatus)
|
||||
&& status != ATTManager.ATT_STATUS_NOT_DETERMINED
|
||||
&& _initialAttStatus != status)
|
||||
{
|
||||
// 上报点位:
|
||||
Analytics.AttResult(status, _attType);
|
||||
}
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case ATTManager.ATT_STATUS_NOT_DETERMINED:
|
||||
// ATT 状态未知, 请求弹窗
|
||||
RequestAttDialog();
|
||||
break;
|
||||
case ATTManager.ATT_STATUS_RESTRICTED:
|
||||
case ATTManager.ATT_STATUS_DENIED:
|
||||
// ATT 状态受限, 或者被拒绝, 不请求广告
|
||||
break;
|
||||
case ATTManager.ATT_STATUS_AUTHORIZED:
|
||||
// ATT 状态已授权, 请求广告
|
||||
StartAdService();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ad Services
|
||||
|
|
|
|||
Loading…
Reference in New Issue