Issue with FCM Migration to HTTP v1

9 views
Skip to first unread message

M-STAT

unread,
9:18 AM (3 hours ago) 9:18 AM
to Firebase Google Group
Hello all,

We are facing an issue with the FCM migration to HTTP v1 and I was wondering if anyone else had similar issues and if there's a quick solution to our problem.

We have created our own custom push notification SDK for android which was built around the legacy FCM API. Our library worked perfectly well with the previous API but after trying to migrate to HTTP v1 it fails to parse the notification data.

The issue arises from the type of data that is being transferred. The old API used to be able to transfer custom objects in the data whereas the HTTP v1 seems to need everything to be a string. 

Are we missing something? Is there a way for us to keep the old SDK and somehow feed it appropriate data through the new API? If not, the whole library needs to be updated as well as every application we have created that uses the old version of the library.

I am attaching below our old handler as well as the new one. Please let me know if there's a mistake or if there is a workaround this issue which would not require an update of the library and consequently the apps using it.

OLD API (pma and user are the custom objects which are of the wrong type using the new api): 
$data = [ 'payload' => [ 'gcm' => [ 'header' => $this->data['notification']['gcm']['header'], 'text' => $this->data['notification']['message'], 'sound' => $this->data['notification']['gcm']['sound'], 'vibration' => $this->data['notification']['gcm']['vibration'], 'color' => $this->data['notification']['gcm']['color'], 'icon' => $this->data['notification']['gcm']['icon'] ], 'pma' => $this->data['pma'], 'user' => $this->data['user'], ], 'collapse_key' => $this->data['notification']['gcm']['collapse_key'], 'time_to_live' => $extras['time_to_live'], 'delay_while_idle' => null, ];


NEW API:

$data = [ 'message' => [ 'notification' => [ 'title' => $this->data['notification']['gcm']['header'], 'body' => $this->data['notification']['message'], ], 'data' => [ 'pma' => $this->data['pma'], 'user' => $this->data['user'], ], 'android' => [ 'collapse_key' => $this->data['notification']['gcm']['collapse_key'], 'ttl' => $extras['time_to_live'], 'delay_while_idle' => null, 'notification'=> [ 'icon' => $this->data['notification']['gcm']['icon'], 'sound' => $this->data['notification']['gcm']['sound'], 'default_vibrate_timings' => $this->data['notification']['gcm']['vibration'], 'color' => $this->data['notification']['gcm']['color'], ] ], ], ];  

Any help would be very much appreciated,
Best regards!

Joe Spiro

unread,
9:23 AM (3 hours ago) 9:23 AM
to Firebase Google Group
Hello,

Sorry to hear about the issues you have faced. We recently updated our migration docs with information about this exact change: Objects can still be sent but must be stringified ahead of time.

Give that a try and see how it goes.

Reply all
Reply to author
Forward
0 new messages