У меня проблема с отправкой уведомлений pu sh из WordPress -> Firebase -> iOS. На устройствах Android это работает отлично.
Все отлично работает, когда я отправляю уведомления из проекта firebase, но когда я пытаюсь отправить уведомление из WP, приложение не отвечает. Я пытался с помощью следующего кода:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
print("Notifications granted")
}
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications()
FirebaseApp.configure()
// -----------------------------------------------------------------
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print("MessageID : \(userInfo["gcm_message_id"]!)")
print(userInfo)
}
//MARK: Printing device ID
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().delegate = self
InstanceID.instanceID().instanceID { (result, error) in
if let error = error {
print("Error fetching remote instance ID: \(error)")
} else if let result = result {
print("Remote instance ID token: \(result.token)")
}
}
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let receivedNews: [String: Any] = ["id" : response.notification.request.content.userInfo["id"] ?? ""]
print("FIRST RECEIVED: \(receivedNews.first)")
print("USERINFO: \(response.notification.request.content.userInfo)")
// NotificationCenter.default.post(name: .stickyTaped, object: nil, userInfo: receivedNews)
}