forked from Blendman974/faceclaw
feat: configure notification filtering and dismiss all notifications
This commit is contained in:
10 files changed
+263
-13
No files matched your search
@@ -26,6 +26,16 @@ export function iosNotificationState(): AncsState { return active?.state ?? 'dis
|
||||
export function readActiveNotifications(maxNotifications = 50) { return active?.read(maxNotifications) ?? [] }
|
||||
export function invokeNotificationAction(key: string, index: number): boolean { return active?.action(key,index) ?? false }
|
||||
export function dismissNotification(key: string): boolean { return active?.dismiss(key) ?? false }
|
||||
export function dismissAllNotifications(): boolean {
|
||||
const client = active
|
||||
if (!client) return false
|
||||
// Snapshot: removals may arrive while dismissal requests are being sent.
|
||||
let accepted = true
|
||||
for (const notification of [...client.read(ALL_NOTIFICATIONS)]) {
|
||||
if (!client.dismiss(notification.key)) accepted = false
|
||||
}
|
||||
return accepted
|
||||
}
|
||||
export function onAndroidNotificationPosted(listener: (key: string) => void): () => void {
|
||||
listeners.add(listener); return () => { listeners.delete(listener) }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user