A bit of notification turn on reminder
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user