Bark/Common/GroupMuteSettingManager.swift

36 lines
1002 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// GroupMuteSettingManager.swift
// Bark
//
// Created by huangfeng on 11/6/24.
// Copyright © 2024 Fin. All rights reserved.
//
import UIKit
let kGroupMuteSettingKey = "groupMuteSettings"
/// NotificationServiceExtension NotificationContentExtension
class GroupMuteSettingManager: NSObject {
let defaults = UserDefaults(suiteName: "group.bark")
var settings: [String: Date] = [:] {
didSet {
defaults?.set(settings, forKey: kGroupMuteSettingKey)
}
}
override init() {
super.init()
if let settings = defaults?.dictionary(forKey: kGroupMuteSettingKey) as? [String: Date] {
self.settings = settings
}
//
for setting in settings {
if setting.value < Date() {
self.settings.removeValue(forKey: setting.key)
}
}
}
}