Когда приложение в фоновом режиме или неактивно, правильное нажатие на уведомление срабатывает:
Код: Выделить всё
userNotificationCenter(_:didReceive:withCompletionHandler:)Я использую:
- Приложение SwiftUI @main
- для AppDelegate
Код: Выделить всё
@UIApplicationDelegateAdaptor - делегат установлен вручную
Код: Выделить всё
UNUserNotificationCenter - отключено
Код: Выделить всё
FirebaseAppDelegateProxy - Нет SceneDelegate
- Проверка параметров запуска?\[.remoteNotification\] (не запускается на iOS 15 и более поздних версиях)
- Добавление приложения(\_:continue:restorationHandler:)
- Предотвращение появления баннеров во время запуска (предложение от ChatGPT, но ничего не изменилось)
У меня есть код:
Код: Выделить всё
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey : Any]?
) -> Bool {
UNUserNotificationCenter.current().delegate = self
return true
}
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
handleNotificationTap(response.notification.request.content.userInfo)
completionHandler()
}
public func handleNotificationTap(_ userInfo: [AnyHashable : Any]) {
let id = userInfo["notification_id"]
let notificationId = (id as? Int).map(String.init) ?? (id as? String)
if let finalId = notificationId {
Analytics.track("notification_opened", parameters: ["notification_id": finalId])
} else {
Analytics.track(
"notificationTappedWithoutID",
parameters: ["payload": userInfo]
)
}
}
Буду признателен за любую помощь. искал это уже несколько ночей.
Подробнее здесь: https://stackoverflow.com/questions/798 ... -is-killed
Мобильная версия