update: 优化 iOS Noti 打点逻辑
--story=1020629 --user=yufei.hu 【中台】【SDK】加入消息弹框管理,中台 noti_perm 打点逻辑优化 https://www.tapd.cn/33527076/s/1152197 Signed-off-by: huyufei <yufei.hu@castbox.fm>main
parent
cfe81b5583
commit
80e38bf85d
|
|
@ -165,7 +165,6 @@ namespace Guru.Notification
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// SDK 33 以上,请求弹窗
|
// SDK 33 以上,请求弹窗
|
||||||
|
|
||||||
bool hasPermission = Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION);
|
bool hasPermission = Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION);
|
||||||
if (hasPermission)
|
if (hasPermission)
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +172,7 @@ namespace Guru.Notification
|
||||||
callback?.Invoke(STATUS_GRANTED);
|
callback?.Invoke(STATUS_GRANTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug.Log($"[SDK][Noti] --- #4 SDK {sdkInt} :: Ask Post Permission");
|
Debug.Log($"[SDK][Noti] --- #3 SDK {sdkInt} :: Ask Post Permission");
|
||||||
Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION, SetupPermissionCallbacks());
|
Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION, SetupPermissionCallbacks());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ namespace Guru.Notification
|
||||||
|
|
||||||
private static bool _initOnce;
|
private static bool _initOnce;
|
||||||
private static int _waitSeconds = 30;
|
private static int _waitSeconds = 30;
|
||||||
|
private string SavedNotiPermStatus
|
||||||
|
{
|
||||||
|
get => PlayerPrefs.GetString(nameof(SavedNotiPermStatus), "");
|
||||||
|
set => PlayerPrefs.SetString(nameof(SavedNotiPermStatus), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private string _notiStatus;
|
private string _notiStatus;
|
||||||
|
|
@ -28,7 +33,10 @@ namespace Guru.Notification
|
||||||
if (_initOnce) return;
|
if (_initOnce) return;
|
||||||
_initOnce = true;
|
_initOnce = true;
|
||||||
|
|
||||||
_notiStatus = STATUS_NOT_DETERMINED;
|
_notiStatus = SavedNotiPermStatus;
|
||||||
|
if (string.IsNullOrEmpty(_notiStatus))
|
||||||
|
_notiStatus = STATUS_NOT_DETERMINED;
|
||||||
|
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
InitPlugins();
|
InitPlugins();
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -71,26 +79,34 @@ namespace Guru.Notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateStatus()
|
private void UpdateStatus()
|
||||||
{
|
{
|
||||||
var status = iOSNotificationCenter.GetNotificationSettings().AuthorizationStatus;
|
string status = STATUS_NOT_DETERMINED;
|
||||||
switch (status)
|
var authorizationStatus = iOSNotificationCenter.GetNotificationSettings().AuthorizationStatus;
|
||||||
|
switch (authorizationStatus)
|
||||||
{
|
{
|
||||||
case AuthorizationStatus.Authorized:
|
case AuthorizationStatus.Authorized:
|
||||||
_notiStatus = STATUS_GRANTED;
|
status = STATUS_GRANTED;
|
||||||
break;
|
break;
|
||||||
case AuthorizationStatus.Denied:
|
case AuthorizationStatus.Denied:
|
||||||
_notiStatus = STATUS_DENIDED;
|
status = STATUS_DENIDED;
|
||||||
break;
|
break;
|
||||||
case AuthorizationStatus.NotDetermined:
|
case AuthorizationStatus.NotDetermined:
|
||||||
_notiStatus = STATUS_NOT_DETERMINED;
|
status = STATUS_NOT_DETERMINED;
|
||||||
break;
|
break;
|
||||||
case AuthorizationStatus.Provisional:
|
case AuthorizationStatus.Provisional:
|
||||||
_notiStatus = STATUS_PROVISIONAL;
|
status = STATUS_PROVISIONAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Debug.Log($"[SDK][Noti][iOS] --- Unmarked AuthorizationStatus: {status}");
|
Debug.Log($"[SDK][Noti][iOS] --- Unmarked AuthorizationStatus: {status}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetGrantStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetGrantStatus(string status)
|
||||||
|
{
|
||||||
|
_notiStatus = status;
|
||||||
|
SavedNotiPermStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,16 @@ namespace Guru.Notification
|
||||||
// 初始化标志位
|
// 初始化标志位
|
||||||
private static bool _initOnce;
|
private static bool _initOnce;
|
||||||
|
|
||||||
private static string DEFAULT_USER_STATUS = "not_determined";
|
private static string DefaultPermissionStatus
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
#if UNITY_IOS
|
||||||
|
return "not_determined";
|
||||||
|
#endif
|
||||||
|
return "denied";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 初始化
|
#region 初始化
|
||||||
|
|
||||||
|
|
@ -77,8 +85,8 @@ namespace Guru.Notification
|
||||||
Agent.RequestPermission(callback);
|
Agent.RequestPermission(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DEFAULT_USER_STATUS}");
|
Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DefaultPermissionStatus}");
|
||||||
callback?.Invoke(DEFAULT_USER_STATUS);
|
callback?.Invoke(DefaultPermissionStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsPermissionGranted()
|
public static bool IsPermissionGranted()
|
||||||
|
|
@ -92,8 +100,8 @@ namespace Guru.Notification
|
||||||
|
|
||||||
if(Agent != null) return Agent.GetStatus();
|
if(Agent != null) return Agent.GetStatus();
|
||||||
|
|
||||||
Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DEFAULT_USER_STATUS}");
|
Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DefaultPermissionStatus}");
|
||||||
return DEFAULT_USER_STATUS;
|
return DefaultPermissionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue