Legacy HTTP FCM migration guide
Migration timeline
If you use Mobile Push Notifications, complete the steps in this guide before June 2024.
Google is deprecating the legacy FCM HTTP API in June 2024. Following Firebase guidance, PubNub is moving from the legacy HTTP API to the HTTP v1 API. PubNub will stop supporting the legacy API when Google removes it.
This change affects how you publish Android push notifications through Mobile Push Notifications.
Update your keyset configuration
When you enable Push Notifications on your app's keyset in the Admin Portal, provide the private key that PubNub uses to communicate with FCM.
In legacy HTTP FCM, you pasted the Firebase Server Key into your app's keyset in the Admin Portal. For HTTP v1, generate and download the FCM private key file, then upload it in the Admin Portal.
Read Configure Account Settings for step-by-step setup of your Firebase Cloud Messaging and PubNub accounts.
Update your push payload
For Android push notifications, include the FCM payload when you publish a message so PubNub can parse it.
The payload object changed from pn_gcm
(legacy HTTP FCM) to pn_fcm
(HTTP v1). The structures differ.
PubNub continues to support pn_gcm
for simple payloads. The push server remaps the legacy payload to the v1 spec when possible.
Some payloads that worked before may be rejected by HTTP v1. The legacy spec was more forgiving.
If you see errors, update your JSON to match the HTTP v1 FCM specification.
See sample payloads:
- Legacy HTTP FCM
- New HTTP v1 FCM
{
"pn_debug": true,
"pn_gcm": {
"notification": {
"body": "common-body",
"content_available": true,
"sound": "default"
}
}
}
{
"pn_debug": true,
"pn_fcm": {
"notification": {
"body": "common-body"
},
"android": {
"collapse_key": "group",
"data": {
"age": "10"
},
"ttl": "30s",
"notification": {
"sound": "default"
}
show all 18 linesRefer to Construct the Push Payload for details.
Possible payload formatting issues
To avoid remapping issues after migrating to pn_fcm
, ensure values in the data
object are strings. Do not include the topic
field; PubNub sets it automatically in the pn_fcm
payload.