You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
3.1 KiB

/**
* DailyNotificationConfig.swift
* Daily Notification Plugin for Capacitor
*
* Provides configuration options for the notification plugin
*/
import Foundation
/// Configuration options for the DailyNotification plugin
///
/// This singleton structure provides configurable options that can be modified
/// to customize the plugin's behavior.
public struct DailyNotificationConfig {
/// Shared instance for singleton access
public static var shared = DailyNotificationConfig()
/// Maximum number of notifications that can be scheduled per day
public var maxNotificationsPerDay = 10
/// Default timezone for notifications when none is specified
public var defaultTimeZone = TimeZone.current
/// Whether debug logging is enabled
public var loggingEnabled = true
/// Number of days to retain delivered notifications
public var retentionDays = 7
/// Whether adaptive scheduling is enabled
public var adaptiveSchedulingEnabled = true
/// Battery level thresholds for adaptive scheduling
public struct BatteryThresholds {
public static let critical = 15
public static let low = 30
public static let medium = 50
}
/// Time intervals for different battery levels (in seconds)
public struct SchedulingIntervals {
public static let critical = TimeInterval(4 * 60 * 60) // 4 hours
public static let low = TimeInterval(2 * 60 * 60) // 2 hours
public static let medium = TimeInterval(60 * 60) // 1 hour
public static let normal = TimeInterval(30 * 60) // 30 minutes
}
/// Wake lock duration based on battery level (in seconds)
public struct WakeLockDurations {
public static let critical = TimeInterval(30) // 30 seconds
public static let low = TimeInterval(45) // 45 seconds
public static let normal = TimeInterval(60) // 1 minute
}
private init() {}
/// Resets all configuration options to their default values
public mutating func resetToDefaults() {
maxNotificationsPerDay = 10
defaultTimeZone = TimeZone.current
loggingEnabled = true
retentionDays = 7
adaptiveSchedulingEnabled = true
}
/// Validates and sets the maximum notifications per day
/// - Parameter value: The new maximum notifications value
/// - Throws: DailyNotificationError if the value is invalid
public mutating func setMaxNotificationsPerDay(_ value: Int) throws {
guard value > 0 else {
throw DailyNotificationError.invalidParameters("Max notifications per day must be greater than 0")
}
maxNotificationsPerDay = value
}
/// Validates and sets the retention days
/// - Parameter value: The new retention days value
/// - Throws: DailyNotificationError if the value is invalid
public mutating func setRetentionDays(_ value: Int) throws {
guard value > 0 else {
throw DailyNotificationError.invalidParameters("Retention days must be greater than 0")
}
retentionDays = value
}
}