Reputation: 564
We are using firebase to send notification to iOS and Android devices. Tried to send to native iOS app too, that didn't work either. The notifications are working just fine with Android but not reaching iOS devices. What's weird is that the response from firebase is success. The same app is able to get notification from the cordova site
Here are the request and response for FCM:
Request:{"data":{"title":"Test notification from server code","body":"detailContent : some test data"},"to":"foqwNQ2JATY:APA91bHZRz6L7z6q3zyItYBh0eNaMv25d0CPjzPfbT4tTRrxNrkdKYwQM2pqvB-Q7ry3AEwCs8IduuYVBz834muWXnwjvt5I7mbMPbpPCw17bbBqFG4hhNdqDIO0xRdDQir8P2hz66WE","priority":"high"}
Response:{"multicast_id":6317092041813746870,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1519618961399427%7c1174a8f9fd7ecd"}]}
Upvotes: 1
Views: 2755
Reputation: 1560
Your payload must be like:
{
"to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
},
"data" : {
"Nick" : "Mario",
"Room" : "PortugalVSDenmark"
}}
Having all data under data does not trigger any notification in iOS even though Firebase returns a successful request because the forwarded APNS payload is not correct. Besides the proper way should be to follow the GCM or FCM payload recommendations, which is to use both notification for the notification message and data for custom key/value pairs.
When FCM Send data to APNS it convert it into APNs payload. It set values of notification in aps
tag i.e.
{
"aps" : {
"alert" : {
"title" : "Portugal vs. Denmark",
"body" : "Portugal vs. Denmark",
}
},
"Nick" : "Mario",
"Room" : "PortugalVSDenmark" }
For More info please refer this.
Upvotes: 5