Sorry if this is a dumb question, I am setting up Firebase with APNs for the first time. I am working in Swift with an iOS app and I have apns messages working separately without Firebase -- so remote push notifications are received on the device in background and while running app. I can use this tool https://github.com/noodlewerk/NWPusher to send notifications on Sandbox and Production apns certs successfully by sending this json blob as an example:
{"aps":{"alert":"Testing","badge":1,"sound":"default"}}
However, now I am trying to incorporate Firebase and not getting the same behavior on the iOS device.
I have Firebase messaging setup and the app prints remote messages with "shouldEstablishDirectChannel = true"
but APNs is never received (with this set to false then device doesn't print anything). No push notifications are received on device. I don't believe APNs is being mapped correctly for Firebase messages as I cannot get the device to display push notifications in the same way that I can with NWPusher on strictly APNs Sandbox and Production certs. Firebase app console has the app's .p12 apns cert (which is working fine for apns without firebase involved)
Here's a sample request I try to send to https://fcm.googleapis.com/fcm/send
{
"to" : "eqkeyhereinifnbe",
"collapse_key" : "type_a",
"data" : {
"body" : "Notification",
"title": "testing",
"key_1" : "Data for key one",
"key_2" : "Hello Meowww",
}
}
API returns a success response:
{
"multicast_id": 634054476369,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:15329261441bfd36cccfb49c"
}
]
}
In iOS app's AppDelegate:
func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
print("Received data message: \(remoteMessage.appData)!")
}
^prints the message successfully from the api on device:
Received data message: [AnyHashable("collapse_key"): type_a, AnyHashable("key_1"): Data for key one, AnyHashable("from"): 9861340, AnyHashable("key_2"): Hello Meowww, AnyHashable("body"): Notification, AnyHashable("title"): testing]!
However this received message doesn't do any of the APNs notification magic to an iOS device. I tried to send the same json blob to Firebase API that works fine in NWPusher: {"aps":{"alert":"Testing","badge":1,"sound":"default"}}
, but device does not display the notification. Why? How troubleshoot this to make Firebase send the same APNs notification to show notifications on device?