havesource / cordova-plugin-push

Register and receive push notifications
MIT License
144 stars 273 forks source link

Android: Update your apps to the latest Firebase Cloud Messaging APIs and SDKs #257

Open appzer opened 5 months ago

appzer commented 5 months ago

Hi, currently i use a self modified version of the older plugin > https://github.com/phonegap/phonegap-plugin-push All works fine at least with the latest Android version 13 & 14.

But yesterday i got the following message from Google! What needs to be adjusted on the Cordova app/plugin and on the server side. Can someone explain!

Thanks Kevin

firebase

nbadiganti commented 4 months ago

+1 following for this change

andreszs commented 3 months ago

I'm also receiving the same warnings from Google, hopefully the Cordova plugin has nothing to do.

You need to change the server side code only to use the HTTP v1 API to send the notifications. I remember trying to switch to this API years ago, but failed due to certain server requirements that were absolutely impossible to meet.

viking2917 commented 2 months ago

They explain in the email which things need to be done based on your usage. In my case, it was to update the legacy protocol to v1 of the API, and stop using static server keys.

Documentation for how to do that is here: https://firebase.google.com/docs/cloud-messaging/migrate-v1#node.js_2

Basically one has to:

1) use a different url 2) stop using a global authorization key and use oAuth v2, and 3) update the payload to a new structure

For #2, the oAuth, my backend is in PHP and I found this very helpful for that part of the process: https://stackoverflow.com/questions/65633126/generating-oauth-token-for-firebase-cloud-messaging-php

The challenge I am now facing is that background notifications seem to be not processed in quite the same way. I have filed a separate ticket for that: https://github.com/havesource/cordova-plugin-push/issues/266