jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.26k stars 613 forks source link

Use new FCM APIs #546

Closed sevdog closed 7 months ago

sevdog commented 4 years ago

As of now FCM notifications are sent to https://fcm.googleapis.com/fcm/send which is a legacy API.

Messages should be sent to current API endpoint:

https://fcm.googleapis.com/v1/{parent=projects/*}/messages:send
shamilbuzz commented 4 years ago

You can change the API Endpoint for FCM by setting an attribute in push notification config as follows,

PUSH_NOTIFICATIONS_SETTINGS = {
    "FCM_API_KEY": "********",
    "FCM_POST_URL": "https://fcm.googleapis.com/v1/projects/{project_id}/messages:send",
     .......
     .......
}
sevdog commented 4 years ago

What concern me is that since APIs are different they accept different parameter format.

Looking into Firebase docs seems that API v1 has a different param signature from legacy one.

There is an official guide which explains why just changing URL is not enough.

williams9438 commented 3 years ago

What concern me is that since APIs are different they accept different parameter format.

Looking into Firebase docs seems that API v1 has a different param signature from legacy one.

There is an official guide which explains why just changing URL is not enough.

Where you able to solve this??

sevdog commented 3 years ago

Where you able to solve this??

ATM I do not have time to work on a PR about this issue.

Since Google is still maintaining legacy API (to keep alive many legacy app) this is not an high-priority.

When I have some free time I could try to address this.

sevdog commented 3 years ago

This could be accomplished by using official firebase-admin or by using the example code provided by firebase guide.

shamilbuzz commented 3 years ago

What concern me is that since APIs are different they accept different parameter format.

Looking into Firebase docs seems that API v1 has a different param signature from legacy one.

There is an official guide which explains why just changing URL is not enough.

First of all, sorry to be not responsive here as it's my secondary github account. Seems like I went for a winter sleep :P

Thanks, @sevdog for pointing the issue with my short reply. Yes, just changing URL is not enough here and actually its not the true solution in any system anywhere when you are upgrading specifically any kind of API version. So AT THAT TIME, how I solved was by overriding few core methods for myself following the same official docuement that you had also mentioned in your reply. So I actually had to customize the library on a short notice to meet my deadline. But unfortunately, that was not something to be shared with public or send a PR as well :D

@sevdog , thanks again for your latest suggestion, I will go through this new library as I predict that I will again have to work on push notifications soon and quite on a large scale TBH. :D

sevdog commented 1 year ago

The legacy API are deprecated from yesterday and will be removed on June 20th 2024

sevdog commented 1 year ago

Looking aroud there is this package which implements only FCM: https://github.com/xtrinch/fcm-django/

It can be taken as an example.