Untitled
unknown
plain_text
a year ago
664 B
10
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