Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for FCM HTTP v1 #588

Open
CR4567 opened this issue Feb 12, 2021 · 19 comments
Open

Support for FCM HTTP v1 #588

CR4567 opened this issue Feb 12, 2021 · 19 comments

Comments

@CR4567
Copy link

CR4567 commented Feb 12, 2021

Hi,

are there plans to support the new HTTP V1 format of Google FCM?
It's google so you never know what will happen to the legacy HTTP version.

If I find some time, I will check how to integrate the authentication mechanism.
Changing URL and message body should be the easy part.

@aried3r
Copy link
Member

aried3r commented Feb 15, 2021

I have the same thoughts regarding Google perhaps dropping legacy FCM at some point. However I don't have the time right now to implement the new format. But we're of course happy for any PR coming our way. :)

@mirkode
Copy link

mirkode commented May 12, 2021

I would definitely try and help, but don't really know where to start.
I think it should be working by using googleauth, but I am not sure what the best way would be to pass in the secrets.json and the project_id for the new way of authentication.

As far as I can see the only part that would need to change is in the gcm/delivery.rb no?

Maybe do something like this?

def obtain_access_token
  scope = 'https://www.googleapis.com/auth/cloud-platform'

  authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
    json_key_io: File.open('path-to-authentication-file.json'), # TODO: here we would need the path to the respective file
    scope: scope)

  authorizer.fetch_access_token!
end

def do_post
  access_token = obtain_access_token
  post = Net::HTTP::Post.new(FCM_URI.path, 'Content-Type'  => 'application/json',
                                           'Authorization' => "Bearer #{access_token}")
  post.body = @notification.as_json.to_json
  @http.request(FCM_URI, post)
end

Oh and the URI would need to be changed to something like

@uri = URI.parse("#{host}/v1/projects/#{@app.project_id}/messages:send")

@mirkode
Copy link

mirkode commented May 12, 2021

Because I unfortunately cannot use rpush anymore since I only get a 401 and cannot re-generate a legacy token anymore.

@mirkode
Copy link

mirkode commented May 19, 2021

Forked this gem here and managed to get it working with FCM.

Will try and clean it up in the next couple of days, but unsure if it is good enough for a PR. At least it is working :-)

@wolak88
Copy link

wolak88 commented Jul 7, 2021

@mirkode
Are you willing to create a PR from your fork? I can put some time and clean it up.

@aried3r
Do you have some time to review this code and show the places where it needs some work?

@aried3r
Copy link
Member

aried3r commented Jul 7, 2021

I'm a bit short on time, but there's also other maintainers that maybe can chip in. I definitely welcome contributions, but I'd ask you to add some tests for it as well.

I'd love to discuss this in a PR. Especially how we'd handle all the new fields of the current FCM protocol. I.e. should these be database columns or "just" catch-all serialized hashes/JSON(B) columns or something else altogether.

@mirkode
Copy link

mirkode commented Jul 7, 2021

@wolak88
Sure! There you go: PR
I can also help, if you could instruct me a little. But that might be more complicated in the end?

Anyway, thanks for getting back to me!

@aried3r
Thanks for the feedback. I was also thinking about if it would make sense to store it in the rpush_apps database table, since there are fields for client_id and a (in this case) apn_key, but then - due to quite some time pressure on my side I was not too sure about if I should be fiddling with migrations on top so I went a rather pragmatic route.
And I also think it could definitely use some tests. :-)

@Joe-noh
Copy link

Joe-noh commented Aug 4, 2021

Any update on this?

@imvishi
Copy link

imvishi commented May 16, 2022

Please let us know if we have any updates on this?

@aried3r
Copy link
Member

aried3r commented May 23, 2022

@imvishi, I left an initial review here: #620 (review). Feel free to chime in and leave feedback. I think it's close but I want to make sure we have adequate documentation and tests.

@Ankita9818
Copy link

Any update on this??

@mobits
Copy link

mobits commented Jun 20, 2023

We received an email from Google today stating that "starting June 20, 2024 the legacy Firebase Cloud Messaging (FCM) APIs will be discontinued".

So, we have a year to switch to HTTP v1 API.

Is there any expectation to support the newer API?

@RowanH
Copy link

RowanH commented Jun 20, 2023

Following just got the same email - have been extremely happy with RPush so definitely don't want to migrate away from it. If maintainers have got a beer donation address happy to get some beers delivered to help support updating of API's :)

@AnilRh
Copy link

AnilRh commented Jul 5, 2023

In the same boat. It would be great to know that RPush is planning to support FCM beyond June 20, 2024. I'd be happy offer some beer/kombucha/frappuccino support too.

@paulcarpenter
Copy link

We would also love to see this supported. Also happy to chip in if it helps!

@mazoonit
Copy link

In the same boat, We would love to see this supported.. ready to help also!

@jlamson
Copy link

jlamson commented Dec 6, 2023

Adding our name to the "we just got that email" pile. Looks like there's a timeline for updating to support the correct version of the APIs

@KevinColemanInc
Copy link

KevinColemanInc commented Jan 19, 2024

The MR to support this looks dead:

#620

I am going to move to use https://github.com/miyataka/fcmpush


edit:
fcmpush works great. I lose the db persistence, but now I don't have to run a separate process for push notifications.

@AnilRh
Copy link

AnilRh commented Feb 14, 2024

We have a new MR - #660. Any help to push that forward would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests