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 | ||||
|                 { | ||||
|                     // SDK 33 以上,请求弹窗 | ||||
|                      | ||||
|                     bool hasPermission = Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION); | ||||
|                     if (hasPermission) | ||||
|                     { | ||||
|  | @ -173,7 +172,7 @@ namespace Guru.Notification | |||
|                         callback?.Invoke(STATUS_GRANTED); | ||||
|                         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()); | ||||
|                 } | ||||
|             }); | ||||
|  |  | |||
|  | @ -19,6 +19,11 @@ namespace Guru.Notification | |||
| 
 | ||||
|         private static bool _initOnce; | ||||
|         private static int _waitSeconds = 30; | ||||
|         private string SavedNotiPermStatus | ||||
|         { | ||||
|             get => PlayerPrefs.GetString(nameof(SavedNotiPermStatus), ""); | ||||
|             set => PlayerPrefs.SetString(nameof(SavedNotiPermStatus), value); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         private string _notiStatus; | ||||
|  | @ -28,7 +33,10 @@ namespace Guru.Notification | |||
|             if (_initOnce) return; | ||||
|             _initOnce = true; | ||||
| 
 | ||||
|             _notiStatus = SavedNotiPermStatus; | ||||
|             if (string.IsNullOrEmpty(_notiStatus)) | ||||
|                 _notiStatus = STATUS_NOT_DETERMINED; | ||||
|              | ||||
| #if UNITY_IOS | ||||
|             InitPlugins(); | ||||
| #endif | ||||
|  | @ -71,26 +79,34 @@ namespace Guru.Notification | |||
|         /// </summary> | ||||
|         private void UpdateStatus() | ||||
|         { | ||||
|             var status = iOSNotificationCenter.GetNotificationSettings().AuthorizationStatus; | ||||
|             switch (status) | ||||
|             string status = STATUS_NOT_DETERMINED; | ||||
|             var authorizationStatus = iOSNotificationCenter.GetNotificationSettings().AuthorizationStatus; | ||||
|             switch (authorizationStatus) | ||||
|             { | ||||
|                 case AuthorizationStatus.Authorized: | ||||
|                     _notiStatus = STATUS_GRANTED; | ||||
|                     status = STATUS_GRANTED; | ||||
|                     break; | ||||
|                 case AuthorizationStatus.Denied: | ||||
|                     _notiStatus = STATUS_DENIDED; | ||||
|                     status = STATUS_DENIDED; | ||||
|                     break; | ||||
|                 case AuthorizationStatus.NotDetermined: | ||||
|                     _notiStatus = STATUS_NOT_DETERMINED; | ||||
|                     status = STATUS_NOT_DETERMINED; | ||||
|                     break; | ||||
|                 case AuthorizationStatus.Provisional: | ||||
|                     _notiStatus = STATUS_PROVISIONAL; | ||||
|                     status = STATUS_PROVISIONAL; | ||||
|                     break; | ||||
|                 default: | ||||
|                     Debug.Log($"[SDK][Noti][iOS] --- Unmarked AuthorizationStatus: {status}"); | ||||
|                     break; | ||||
|             } | ||||
| 
 | ||||
|             SetGrantStatus(status); | ||||
|         } | ||||
| 
 | ||||
|         private void SetGrantStatus(string status) | ||||
|         { | ||||
|             _notiStatus = status; | ||||
|             SavedNotiPermStatus = status; | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  |  | |||
|  | @ -17,8 +17,16 @@ namespace Guru.Notification | |||
|         // 初始化标志位 | ||||
|         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 初始化 | ||||
| 
 | ||||
|  | @ -77,8 +85,8 @@ namespace Guru.Notification | |||
|                 Agent.RequestPermission(callback); | ||||
|                 return; | ||||
|             } | ||||
|             Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DEFAULT_USER_STATUS}"); | ||||
|             callback?.Invoke(DEFAULT_USER_STATUS); | ||||
|             Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DefaultPermissionStatus}"); | ||||
|             callback?.Invoke(DefaultPermissionStatus); | ||||
|         } | ||||
|          | ||||
|         public static bool IsPermissionGranted() | ||||
|  | @ -92,8 +100,8 @@ namespace Guru.Notification | |||
|              | ||||
|             if(Agent != null) return Agent.GetStatus(); | ||||
|              | ||||
|             Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DEFAULT_USER_STATUS}"); | ||||
|             return DEFAULT_USER_STATUS; | ||||
|             Debug.LogError($"[SDK][Noti] --- Agent is missing, return default status: {DefaultPermissionStatus}"); | ||||
|             return DefaultPermissionStatus; | ||||
|         } | ||||
| 
 | ||||
|         #endregion | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue