У меня проблема с тем, что я не могу сейчас прочитать данные push-сообщений.Обычно я получаю сообщение.
Я могу получать оба сообщения, когда приложение находится на переднем плане или в фоновом режиме, когда нажимаю кнопку «Домой».
Но я не вижу данные сообщения в журнале.
AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
...
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable: Any]) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
// With swizzling disabled you must let Messaging know about the message, for Analytics
guard
let aps = data[AnyHashable("notification")] as? NSDictionary,
let alert = aps["alert"] as? NSDictionary,
let body = alert["body"] as? String,
let title = alert["title"] as? String
else {
// handle any error here
return
}
Log.Info("Title: \(title) \nBody:\(body)")
Messaging.messaging().appDidReceiveMessage(data)
// Print full message.
Log.Info(data)
}
...
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
Log.Info("fcmToken \(fcmToken)")
}
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
Log.Info("remort \(remoteMessage.appData)")
}
Данные, которые я отправляю
{
notification : {
"title" : "test title.",
"body" : "test context."
},
data : {
"image" : "http://11.111.111.111:100000000/_img/sample_01.jpg",
"page_url" : "http://11.111.111.111:100000000/Point?address=",
"type" : "point"
}
}
Журналы нельзя просмотреть ни в одной функции.Что мне не хватает?Пожалуйста, дайте мне знать, что не так.
РЕДАКТИРОВАТЬ
Я изменил неправильные данные и изменил местоположение журнала.Но у меня нет никаких логов на меня.
AppDelegate.swift
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable: Any]) {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification
// With swizzling disabled you must let Messaging know about the message, for Analytics
// Print full message.
Log.Info(data)
guard
let aps = data[AnyHashable("notification")] as? NSDictionary,
let body = aps["body"] as? String,
let title = aps["title"] as? String
else {
// handle any error here
return
}
Log.Info("Title: \(title) \nBody:\(body)")
Messaging.messaging().appDidReceiveMessage(data)
}
отправить тестовое сообщение в базе данных

У меня есть две функции messaging
в дополнение к application
функциям приложения.Эти функции сообщений мне не нужны?Эти функции никогда не показывали мне журнал.