All you have to do is import the UserNotifications framework:
import UserNotifications
Also, make sure you match UNUserNotificationCenterDelegate . As a good practice, I would suggest doing this by doing it as extension:
, .
import UIKit
import UserNotifications
class ViewController: UIViewController {
.
.
.
UNUserNotificationCenter.current().delegate = delegateObject
}
extension ViewController: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}
}