@@ -47,7 +47,7 @@ struct NotificationHelper {
47
47
let identifier = UUID ( )
48
48
let dateComponents = getNotificationDateComponents ( for: contact)
49
49
50
- scheduleNotification ( for: contact, dateComponents: dateComponents, identifier: identifier, content: notificationContent)
50
+ scheduleNotification ( for: contact, isBirthdayOrAnniversary : false , dateComponents: dateComponents, identifier: identifier, content: notificationContent)
51
51
}
52
52
53
53
static func addBirthdayNotification( for contact: SelectedContact ) {
@@ -60,7 +60,7 @@ struct NotificationHelper {
60
60
let birthdayIdentifier = UUID ( )
61
61
let birthdayDateComponents = getBirthdayDateComponents ( for: contact)
62
62
63
- scheduleNotification ( for: contact, dateComponents: birthdayDateComponents, identifier: birthdayIdentifier, content: birthdayNotificationContent)
63
+ scheduleNotification ( for: contact, isBirthdayOrAnniversary : true , dateComponents: birthdayDateComponents, identifier: birthdayIdentifier, content: birthdayNotificationContent)
64
64
}
65
65
66
66
static func addAnniversaryNotification( for contact: SelectedContact ) {
@@ -73,7 +73,7 @@ struct NotificationHelper {
73
73
let anniversaryIdentifier = UUID ( )
74
74
let anniversaryDateComponents = getAnniversaryDateComponents ( for: contact)
75
75
76
- scheduleNotification ( for: contact, dateComponents: anniversaryDateComponents, identifier: anniversaryIdentifier, content: anniversaryNotificationContent)
76
+ scheduleNotification ( for: contact, isBirthdayOrAnniversary : true , dateComponents: anniversaryDateComponents, identifier: anniversaryIdentifier, content: anniversaryNotificationContent)
77
77
}
78
78
79
79
static func checkNotificationAuthorizationStatusAndAddRequest( action: @escaping ( ) -> Void ) {
@@ -112,7 +112,11 @@ struct NotificationHelper {
112
112
} else if contact. preferenceIsAnnually ( ) || contact. preferenceIsCustom ( ) {
113
113
components. hour = contact. notification_preference_hour
114
114
components. minute = contact. notification_preference_minute
115
- components. month = contact. notification_preference_custom_month + 1
115
+ if contact. preferenceIsAnnually ( ) {
116
+ components. month = contact. notification_preference_custom_month + 1
117
+ } else if contact. preferenceIsCustom ( ) {
118
+ components. month = contact. notification_preference_custom_month
119
+ }
116
120
components. day = contact. notification_preference_custom_day
117
121
components. year = contact. notification_preference_custom_year
118
122
}
@@ -158,7 +162,11 @@ struct NotificationHelper {
158
162
dateComponents. weekday = contact. notification_preference_weekday+ 1
159
163
dateComponents. weekOfMonth = contact. notification_preference_week_of_month
160
164
} else if contact. preferenceIsAnnually ( ) || contact. preferenceIsCustom ( ) {
161
- dateComponents. month = contact. notification_preference_custom_month+ 1
165
+ if contact. preferenceIsAnnually ( ) {
166
+ dateComponents. month = contact. notification_preference_custom_month+ 1
167
+ } else if contact. preferenceIsCustom ( ) {
168
+ dateComponents. month = contact. notification_preference_custom_month
169
+ }
162
170
dateComponents. day = contact. notification_preference_custom_day
163
171
dateComponents. year = contact. notification_preference_custom_year
164
172
dateComponents. hour = contact. notification_preference_hour
@@ -216,13 +224,13 @@ struct NotificationHelper {
216
224
return anniversaryDateComponents
217
225
}
218
226
219
- static func scheduleNotification( for contact: SelectedContact , dateComponents: DateComponents , identifier: UUID , content: UNMutableNotificationContent ) {
227
+ static func scheduleNotification( for contact: SelectedContact , isBirthdayOrAnniversary : Bool , dateComponents: DateComponents , identifier: UUID , content: UNMutableNotificationContent ) {
220
228
var calendarTrigger : UNCalendarNotificationTrigger ?
221
229
var timeIntervalTrigger : UNTimeIntervalNotificationTrigger ?
222
230
var request : UNNotificationRequest
223
231
224
232
// quarterly notifications are handled by UNTimeIntervalNotificationTrigger instead of UNCalendarNotificationTrigger, so we handle them separately
225
- if contact. preferenceIsQuarterly ( ) {
233
+ if contact. preferenceIsQuarterly ( ) && !isBirthdayOrAnniversary {
226
234
let oneDay : Double = 86400 // seconds
227
235
// set a recurring time interval for every 90 days
228
236
timeIntervalTrigger = UNTimeIntervalNotificationTrigger ( timeInterval: ( oneDay*90) , repeats: true )
0 commit comments