feat: implement core notification functionality for iOS and Android - Add settings management, proper error handling, and platform-specific implementations
This commit is contained in:
50
ios/Plugin/DailyNotificationError.swift
Normal file
50
ios/Plugin/DailyNotificationError.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* DailyNotificationError.swift
|
||||
* Daily Notification Plugin for Capacitor
|
||||
*
|
||||
* Defines error types and handling for the notification plugin
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Represents possible errors that can occur within the DailyNotification plugin
|
||||
///
|
||||
/// These errors provide specific failure cases and associated messages for better
|
||||
/// error handling and debugging in the notification scheduling process.
|
||||
public enum DailyNotificationError: Error {
|
||||
/// Thrown when required parameters are missing or invalid
|
||||
case invalidParameters(String)
|
||||
|
||||
/// Thrown when notification permissions have not been granted
|
||||
case permissionDenied
|
||||
|
||||
/// Thrown when notification scheduling fails
|
||||
case schedulingFailed(String)
|
||||
|
||||
/// Thrown when time format is invalid (should be HH:mm)
|
||||
case invalidTimeFormat
|
||||
|
||||
/// Thrown when provided timezone identifier is invalid
|
||||
case invalidTimezone
|
||||
|
||||
/// Thrown when priority value is not one of: high, default, low
|
||||
case invalidPriority
|
||||
|
||||
/// Human-readable error messages for each error case
|
||||
public var message: String {
|
||||
switch self {
|
||||
case .invalidParameters(let detail):
|
||||
return "Invalid parameters: \(detail)"
|
||||
case .permissionDenied:
|
||||
return "Notification permissions not granted"
|
||||
case .schedulingFailed(let reason):
|
||||
return "Failed to schedule notification: \(reason)"
|
||||
case .invalidTimeFormat:
|
||||
return "Invalid time format. Expected HH:mm"
|
||||
case .invalidTimezone:
|
||||
return "Invalid timezone identifier"
|
||||
case .invalidPriority:
|
||||
return "Invalid priority value. Expected 'high', 'default', or 'low'"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user