parent
34ae9e3f0b
commit
cfe81b5583
|
|
@ -18,7 +18,6 @@ namespace Guru.Notification
|
||||||
|
|
||||||
private bool _initOnce = false;
|
private bool _initOnce = false;
|
||||||
private string _notiStatus;
|
private string _notiStatus;
|
||||||
private bool _isPluginsInited = false;
|
|
||||||
|
|
||||||
private string SavedNotiPermStatus
|
private string SavedNotiPermStatus
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +37,6 @@ namespace Guru.Notification
|
||||||
if (!string.IsNullOrEmpty(SavedNotiPermStatus))
|
if (!string.IsNullOrEmpty(SavedNotiPermStatus))
|
||||||
{
|
{
|
||||||
_notiStatus = SavedNotiPermStatus;
|
_notiStatus = SavedNotiPermStatus;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
|
|
@ -108,8 +106,6 @@ namespace Guru.Notification
|
||||||
{
|
{
|
||||||
AndroidNotificationCenter.Initialize();
|
AndroidNotificationCenter.Initialize();
|
||||||
Debug.Log($"[Noti][AND] --- Notification Service InitPlugins");
|
Debug.Log($"[Noti][AND] --- Notification Service InitPlugins");
|
||||||
|
|
||||||
_isPluginsInited = true;
|
|
||||||
|
|
||||||
UpdateNotiStatus();
|
UpdateNotiStatus();
|
||||||
}
|
}
|
||||||
|
|
@ -119,8 +115,7 @@ namespace Guru.Notification
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateNotiStatus()
|
private void UpdateNotiStatus()
|
||||||
{
|
{
|
||||||
if (!_isPluginsInited) return;
|
|
||||||
|
|
||||||
TryExecute(() =>
|
TryExecute(() =>
|
||||||
{
|
{
|
||||||
_permissionStatus = AndroidNotificationCenter.UserPermissionToPost;
|
_permissionStatus = AndroidNotificationCenter.UserPermissionToPost;
|
||||||
|
|
@ -148,12 +143,6 @@ namespace Guru.Notification
|
||||||
private PermissionCallbacks _permissionCallbacks;
|
private PermissionCallbacks _permissionCallbacks;
|
||||||
private void RequestAndroidPermission(Action<string> callback = null)
|
private void RequestAndroidPermission(Action<string> callback = null)
|
||||||
{
|
{
|
||||||
if (!_isPluginsInited)
|
|
||||||
{
|
|
||||||
callback?.Invoke(_notiStatus);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateNotiStatus();
|
UpdateNotiStatus();
|
||||||
|
|
||||||
if (_notiStatus == STATUS_GRANTED)
|
if (_notiStatus == STATUS_GRANTED)
|
||||||
|
|
@ -176,6 +165,14 @@ namespace Guru.Notification
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// SDK 33 以上,请求弹窗
|
// SDK 33 以上,请求弹窗
|
||||||
|
|
||||||
|
bool hasPermission = Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION);
|
||||||
|
if (hasPermission)
|
||||||
|
{
|
||||||
|
SetGrantStatus(STATUS_GRANTED);
|
||||||
|
callback?.Invoke(STATUS_GRANTED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Debug.Log($"[SDK][Noti] --- #4 SDK {sdkInt} :: Ask Post Permission");
|
Debug.Log($"[SDK][Noti] --- #4 SDK {sdkInt} :: Ask Post Permission");
|
||||||
Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION, SetupPermissionCallbacks());
|
Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION, SetupPermissionCallbacks());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue