Repository Public
1// Author: Simon-Pierre Boucher — contact@spboucher.ai2// File: App/Integration/Notifier.swift3// Description: System notifications for finished batches of downloads.4import Foundation5import UserNotifications67/// System notifications: only the end of a batch of downloads, and only when the app is not in front.8enum Notifier {9 static func requestAuthorization() {10 UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { _, _ in }11 }12 static func downloadsFinished(count: Int) {13 guard count > 0 else { return }14 let content = UNMutableNotificationContent()15 content.title = "Téléchargements terminés"16 content.body = count == 1 ? "1 titre est disponible hors ligne." : "\(count) titres sont disponibles hors ligne."17 UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: "downloads-finished", content: content, trigger: nil))18 }19}20