Я пытаюсь переопределить UsernotificationCenter на стороне iOS, но когда я это сделаю, мои обратные вызовы обменениями пожарной базы на Flutter Side больше не получают полезную нагрузку уведомлений. < /p>
// Configure Firebase
FirebaseApp.configure()
// [START set_messaging_delegate]
Messaging.messaging().delegate = self
// [END set_messaging_delegate]
// Register for remote notifications. This shows a permission dialog on first run, to
// show the dialog at a more appropriate time move this registration accordingly.
// [START register_for_notifications]
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
< /code>
Если я не переопределяю usernotificationCenter, полезная нагрузка доставляется правильно на TAPS уведомления. Может ли кто -нибудь вести меня о том, как заставить оба работать вместе? < /P>
/// if i remove this then i am able to receive firebase callbacks at flutter side, but currently i am not able to
// [START ios_10_message_handling]
@available(iOS 10, *)
extension AppDelegate {
// Receive displayed notifications for iOS 10 devices.
override func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
#if DEBUG
os_log("Firebase: Received notification in foreground", log: .default, type: .debug)
#endif
if Freshchat.sharedInstance().isFreshchatNotification(userInfo) {
Freshchat.sharedInstance().handleRemoteNotification(userInfo, andAppstate: UIApplication.shared.applicationState)
} else {
// Handle badge count for foreground notifications
let currentBadge = UIApplication.shared.applicationIconBadgeNumber
UIApplication.shared.applicationIconBadgeNumber = currentBadge + 1
}
// Always show notification in foreground
if #available(iOS 14.0, *) {
completionHandler([.banner, .sound, .badge, .list])
} else {
completionHandler([.alert, .sound, .badge])
}
}
override func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
#if DEBUG
os_log("Firebase: User tapped notification", log: .default, type: .debug)
#endif
if Freshchat.sharedInstance().isFreshchatNotification(userInfo) {
Freshchat.sharedInstance().handleRemoteNotification(userInfo, andAppstate: UIApplication.shared.applicationState)
}
completionHandler()
}
}
Я пытаюсь переопределить UsernotificationCenter на стороне iOS, но когда я это сделаю, мои обратные вызовы обменениями пожарной базы на Flutter Side больше не получают полезную нагрузку уведомлений. < /p> [code] // Configure Firebase FirebaseApp.configure()
// Register for remote notifications. This shows a permission dialog on first run, to // show the dialog at a more appropriate time move this registration accordingly. // [START register_for_notifications] if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization( options: authOptions, completionHandler: {_, _ in }) } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } < /code> Если я не переопределяю usernotificationCenter, полезная нагрузка доставляется правильно на TAPS уведомления. Может ли кто -нибудь вести меня о том, как заставить оба работать вместе? < /P> /// if i remove this then i am able to receive firebase callbacks at flutter side, but currently i am not able to // [START ios_10_message_handling] @available(iOS 10, *) extension AppDelegate {