Я обновляю устаревшее приложение для использования UserNotifications
фреймворка.После импорта UserNotifications
в моем AppDelegate.swift
я запрашиваю авторизацию с использованием следующего:
import UserNotifications
///...///
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.requestAuthorization(options: []) { (granted, error) in
print("Granted: \(granted), error: \(error)")
// Enable or disable features based on authorization.
}
Однако всегда выводится следующее:
Granted: false, error: Optional(Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application})
Я пропускаю разрешение илиправо где-то?Если я создаю новый проект и добавляю к нему уведомление, он работает нормально.