update: 添加 Android Target 33 在 Consent 结束后, 弹出 Push Notification 权限的接口
parent
e11b61fa88
commit
ad47a9696b
|
|
@ -129,6 +129,8 @@ namespace Guru
|
||||||
|
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
|
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
|
||||||
|
#elif UNITY_ANDROID
|
||||||
|
CheckPermission(); // [Android] Consent 回调后检查 Push 推送权限
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 内部处理后继逻辑
|
// 内部处理后继逻辑
|
||||||
|
|
@ -222,6 +224,43 @@ namespace Guru
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Android 13 PushNotification Permission
|
||||||
|
|
||||||
|
private const string PERMISSION_POST_NOTIFICATION = "android.permission.POST_NOTIFICATIONS";
|
||||||
|
|
||||||
|
private void CheckPermission()
|
||||||
|
{
|
||||||
|
float delay = 1;
|
||||||
|
Debug.Log($"---- Check PushPermission ---");
|
||||||
|
#if UNITY_ANDROID
|
||||||
|
// 如果已经请求过权限的话, 则不做动作
|
||||||
|
if (UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION))
|
||||||
|
{
|
||||||
|
Debug.Log($"--- PushPermission has passed ---");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Invoke(nameof(RequestNotification), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求Notification
|
||||||
|
/// </summary>
|
||||||
|
private void RequestNotification()
|
||||||
|
{
|
||||||
|
#if UNITY_ANDROID
|
||||||
|
Debug.Log("--- Target 33 Request Notification ---");
|
||||||
|
// Android直接申请授权
|
||||||
|
if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION))
|
||||||
|
{
|
||||||
|
UnityEngine.Android.Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Ad Services
|
#region Ad Services
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,6 @@ namespace Guru
|
||||||
//-------- SetUserProperties ---------
|
//-------- SetUserProperties ---------
|
||||||
InitUserProperties();
|
InitUserProperties();
|
||||||
|
|
||||||
|
|
||||||
bool useKeywords = false;
|
bool useKeywords = false;
|
||||||
bool useIAP = _initConfig.IAPEnabled;
|
bool useIAP = _initConfig.IAPEnabled;
|
||||||
bool appleReview = false;
|
bool appleReview = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue