Untitled
Anonymous
plain_text
10/10/2024 8:47 PM
888 B
19
Indexable
import SwiftUI
import UserNotifications
@main
struct LocalNotificationsDemoApp: App {
let notificationDelegate = NotificationDelegate()
init() {
UNUserNotificationCenter.current().delegate = notificationDelegate
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.banner, .sound])
}
}Editor is loading...
Leave a Comment