olucurious / PyFCM

Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)
http://olucurious.github.io/PyFCM/
MIT License
802 stars 204 forks source link

Migrate from legacy FCM APIs to HTTP v1 #325

Closed jhonsoto-aflore closed 2 months ago

jhonsoto-aflore commented 2 months ago

https://github.com/olucurious/PyFCM/blob/ee73aa44ee1f44833b6dd22e7457f1452862173d/pyfcm/baseapi.py#L27

Apps using the deprecated FCM legacy APIs for HTTP and XMPP should migrate to the HTTP v1 API at the earliest opportunity. Sending messages (including upstream messages) with those APIs was deprecated on June 20, 2023, and will be removed on June 21, 2024.

HTTP requests before: POST https://fcm.googleapis.com/fcm/send

After: POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send

jinwoojimmy commented 2 months ago

@jhonsoto-aflore https://github.com/olucurious/PyFCM/pull/321 It seems like updated version will be released soon.

olucurious commented 2 months ago

Done https://github.com/olucurious/PyFCM/releases/tag/2.0.1

panki commented 2 months ago

@olucurious It doesn't work, migration is not completed. I have a fork where I fixed all the issues. I can do a PR if the author is not gonna complete the migration.

olucurious commented 2 months ago

Please send a PR then

panki commented 2 months ago

@olucurious Sorry for the confusion. I was referring to the version https://github.com/olucurious/PyFCM/pull/319. I just realized you already made the fix in 2.x version. I made almost identical changes a few days ago to make it work. The primary difference is I kept the backward compatibility.

I have one minor comment regarding your version. The FCM token has a 24-hour lifetime, so there is no need to refresh it that often (every 30 minutes).

panki commented 2 months ago

Another possible improvement is obtaining the project ID from the service account key JSON file (project_id attribute) instead of requiring it to be passed as a constructor argument.