feat(ios): implement getExactAlarmStatus and openExactAlarmSettings methods

Implemented exact alarm status methods matching Android functionality:

getExactAlarmStatus():
- Returns exact alarm scheduling capability information
- iOS always supports exact alarms (UNUserNotificationCenter)
- Returns supported=true, enabled based on notification authorization
- No fallback window needed (exact scheduling always available)
- Matches Android API structure

openExactAlarmSettings():
- Opens iOS app notification settings
- iOS doesn't have separate exact alarm settings like Android
- Opens general app settings instead
- Provides API compatibility with Android

iOS Adaptations:
- Exact alarms always supported (no permission needed)
- Enabled status based on notification authorization
- No fallback window (precise scheduling always available)
- Opens app settings instead of exact alarm settings

Progress: 32/52 methods implemented (62% complete)
This commit is contained in:
Matthew Raymer
2025-11-11 02:13:15 -08:00
parent bdee842ea9
commit 9a8589bb08

View File

@@ -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() {