Legacy HTTP FCM migration guide
Migration timeline
Existing users of PubNub's Mobile Push Notifications are recommended to perform the following actions before June 2024.
Following recommendations from Firebase, PubNub has recently been moving away from supporting deprecated Firebase Cloud Messaging (FCM) legacy HTTP FCM APIs towards the new HTTP v1 FCM API and will stop supporting it in June 2024 when Google will be removing it completely.
This involves slight changes in PubNub's process for letting its users publish messages through Mobile Push Notifications on Android devices.
Update your keyset configuration
When you enable Push Notifications on your app's keyset in the Admin Portal, you must let PubNub know what is the private key you want PubNub to use to communicate with the FCM platform.
In the legacy HTTP FCM, you were asked to paste the Firebase Server Key into your app's keyset on the Admin Portal. To migrate to the new HTTP v1 FCM, generate and download the FCM private key file and then upload it onto the Admin Portal.
Read the Configure Account Settings section for detailed instructions on configuring your Firebase Cloud Messaging and PubNub accounts for your application.
Update your push payload
To send push notifications on your Android devices, you must include the appropriate push notification payload for FCM when you publish a message for PubNub to parse it appropriately.
The structure of this payload has been changed from pn_gcm
(legacy HTTP FCM) to pn_fcm
(new HTTP v1 FCM) objects that require different payload structures.
PubNub will continue to support the existing pn_gcm
object for simple payloads. Since pn_gcm
was based on an older and incompatible spec, the push server will attempt to remap the payload to the new FCM spec.
However, it will only work in some cases. Because the older spec was more forgiving, a payload that worked previously would be rejected as an error with the new FCM.
If you experience such issues, update the payload JSON on your apps to match the new 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 the Construct the Push Payload section for details.
Possible payload formatting issues
To avoid remapping issues after migrating to pn_fcm
, make sure the data
object accepts only data of string
type and that you don't include the topic
field in your payload (PubNub automatically sets the topic
field in the pn_fcm
payload).