Skip to content

Instantly share code, notes, and snippets.

View f3z0's full-sized avatar

Gregory Ray f3z0

View GitHub Profile
@f3z0
f3z0 / Rails FCM HTTP v1 API
Created April 18, 2021 03:13
This is how to use Faraday and GoogleAuth to connect to your FCM instance and push to topics
# if you want or need to move off the legacy FCM HTTP endpoints this will get you started
# Use googleauth gem to construct JWT token
def construct_payload(topic, data, notification = nil)
message = {
'topic': "fcm_test",
# 'token': token, # OR, if you want to send to a specific device
'data': {
payload: data.to_json # note we can no longer embed objects within data
},