Cotton code
16 lines · 701 B · SwiftRaw
import Foundationimport UserNotifications/// A notification only when the person must act, once per problem (AppModel.notifyProblems). Permission is asked/// the first time one is needed, never at launch.enum Notifications {    static func post(title: String, body: String) {        UNUserNotificationCenter.current().requestAuthorization(options: [.alert]) { granted, _ in            guard granted else { return }            let content = UNMutableNotificationContent()            content.title = title            content.body = body            UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil))        }    }}