Обмен сообщениями Firebase iOS вызывает проблемы с UsernotificationCenterIOS

Программируем под IOS
Ответить
Anonymous
 Обмен сообщениями Firebase iOS вызывает проблемы с UsernotificationCenter

Сообщение Anonymous »

Я пытаюсь переопределить 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()
}
}
Вот мой код Gist:
👉 https://gist.github.com/anirudhsharma39 ... 773f5fb28d

Подробнее здесь: https://stackoverflow.com/questions/797 ... tioncenter
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»