diff --git a/ios/Plugin/DailyNotificationPlugin.swift b/ios/Plugin/DailyNotificationPlugin.swift index 7bb7a85..20ec425 100644 --- a/ios/Plugin/DailyNotificationPlugin.swift +++ b/ios/Plugin/DailyNotificationPlugin.swift @@ -1278,6 +1278,76 @@ public class DailyNotificationPlugin: CAPPlugin { } } + /** + * Get exact alarm status + * + * Returns detailed information about exact alarm scheduling capability. + * On iOS, exact alarms are always supported via UNUserNotificationCenter. + * + * Equivalent to Android's getExactAlarmStatus method. + */ + @objc func getExactAlarmStatus(_ call: CAPPluginCall) { + print("DNP-PLUGIN: Getting exact alarm status") + + // iOS always supports exact alarms via UNUserNotificationCenter + // Background App Refresh is the closest equivalent to Android's exact alarm permission + // but we can't check it directly - we assume it's enabled if notifications are authorized + notificationCenter.getNotificationSettings { settings in + let notificationsEnabled = settings.authorizationStatus == .authorized + + // iOS supports exact alarms (UNUserNotificationCenter provides precise scheduling) + let supported = true + let enabled = notificationsEnabled // Assume enabled if notifications are authorized + let canSchedule = enabled + let fallbackWindow = "0 minutes" // No fallback needed on iOS - exact scheduling is always available + + let result: [String: Any] = [ + "supported": supported, + "enabled": enabled, + "canSchedule": canSchedule, + "fallbackWindow": fallbackWindow + ] + + print("DNP-PLUGIN: Exact alarm status: supported=\(supported), enabled=\(enabled), canSchedule=\(canSchedule)") + + DispatchQueue.main.async { + call.resolve(result) + } + } + } + + /** + * Open exact alarm settings + * + * Opens iOS notification settings for the app. + * iOS doesn't have separate exact alarm settings like Android. + * + * Equivalent to Android's openExactAlarmSettings method. + */ + @objc func openExactAlarmSettings(_ call: CAPPluginCall) { + print("DNP-PLUGIN: Opening exact alarm settings (iOS: opens app notification settings)") + + // iOS doesn't have separate exact alarm settings + // Open app notification settings instead + if let settingsUrl = URL(string: UIApplication.openSettingsURLString) { + if UIApplication.shared.canOpenURL(settingsUrl) { + UIApplication.shared.open(settingsUrl) { success in + if success { + print("DNP-PLUGIN: Settings opened successfully") + call.resolve() + } else { + print("DNP-PLUGIN: Failed to open settings") + call.reject("Failed to open settings") + } + } + } else { + call.reject("Cannot open settings URL") + } + } else { + call.reject("Invalid settings URL") + } + } + // MARK: - Private Implementation Methods private func setupBackgroundTasks() {