     }
 
     fileprivate func markAsSent(event: Event) {
-        sentNotifications.insert(event.id)
+        var sent = sentNotifications
+        sent.insert(event.id)
+        sentNotifications = sent
     }
 }

    }

    func persistNotificationCache() {
        UserDefaults.standard.set([String(Date().timeIntervalSinceReferenceDate): Array(sentNotifications)], forKey: sentNotificationDictKey)
        UserDefaults.standard.synchronize()
    }


fileprivate typealias EventID = String

class EventNotificationsManager {

    fileprivate var sentNotifications: Set<String> {
        get {
            return Set<String>(UserDefaults.standard.array(forKey: sentNotificationDictKey) as? [String] ?? [])
        }

        set {
            UserDefaults.standard.set(Array(newValue), forKey: sentNotificationDictKey)
        }
    }

    fileprivate var shouldFetchEvents: Bool {
        guard let eventFetchStartTime = eventFetchStartTime else {
