A bit of notification turn on reminder

This commit is contained in:
2026-03-01 05:45:23 +08:00
parent ec46c33c35
commit e91e7b43d2
9 changed files with 190 additions and 14 deletions
+29
View File
@@ -94,4 +94,33 @@ class NotificationService {
payload: payload,
);
}
/// Returns true when the high-priority channel appears to be muted or
/// has sound disabled on the device.
static Future<bool> isHighPriorityChannelMuted() async {
final androidImpl = _plugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>();
if (androidImpl == null) return false;
try {
final impl = androidImpl as dynamic;
final channel = await impl.getNotificationChannel(_highChannelId);
if (channel == null) return false;
final importance = channel.importance as dynamic;
final playSound = channel.playSound as bool?;
if (importance == null) return false;
// importance may be an enum-like value; compare using index if present.
try {
final impIndex = (importance.index is int)
? importance.index as int
: int.parse(importance.toString());
if (impIndex < Importance.high.index) return true;
} catch (_) {}
if (playSound == false) return true;
return false;
} catch (_) {
return false;
}
}
}