Skip to content

Instantly share code, notes, and snippets.

Avatar

Gregory Ray f3z0

View GitHub Profile
@f3z0
f3z0 / Rails FCM HTTP v1 API
Created Apr 18, 2021
This is how to use Faraday and GoogleAuth to connect to your FCM instance and push to topics
View Rails FCM HTTP v1 API
# 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
},