From 573cee7a6f5bb9572eb6bdf7812b120c87865b4c Mon Sep 17 00:00:00 2001 From: YouR97 <952870061@qq.com> Date: Tue, 16 Jul 2024 15:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=8C=87=E5=AE=9Aid=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gameplay/Debug/SROptions.Notification.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Notification.cs b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Notification.cs index b8b4e9f..3f28b8d 100644 --- a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Notification.cs +++ b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Notification.cs @@ -1,6 +1,6 @@ using System.ComponentModel; using System; -using Gameplay.Manager; +using Unity.Notifications.Android; public partial class SROptions { @@ -20,8 +20,24 @@ public partial class SROptions public void CancelNotification() { #if UNITY_ANDROID - Notification.Android.CancelNotification(1); + Notification.Android.CancelNotification(NotificationID); DebugUtil.Log($"取消安卓测试通知,通知id{NotificationID}"); +#endif + } + + [Category("通知相关"), DisplayName("获取指定id通知状态")] + public void GetNotificationStatus() + { +#if UNITY_ANDROID + NotificationStatus notificationStatus = Notification.Android.GetNotificationStatus(NotificationID); + string content = notificationStatus switch + { + NotificationStatus.Unavailable => "无法确定指定通知的状态。仅支持 Android Marshmallow (6.0) 及以上版本。", + NotificationStatus.Scheduled => $"id为{NotificationID}的通知已排定但尚未送达。", + NotificationStatus.Delivered => $"id为{NotificationID}的通知已发送(显示在状态栏中)。", + _ => $"找不到指定id为{NotificationID}的通知。", + }; + DebugUtil.Log(content); #endif } } \ No newline at end of file