Вам необходимо подтвердить UNUserNotificationCenterDelegate в вашем классе AppDelegate;
import UserNotifications
class AppDelegate : UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
}
, затем вы можете вызвать эту функцию в своем классе ViewController, не забывайте снова импортировать уведомления пользователя в ViewController;
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}