Skip to content

Instantly share code, notes, and snippets.

@e2po
Created May 14, 2018 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e2po/fd8f8218d2ed331ad215edec1f793639 to your computer and use it in GitHub Desktop.
Save e2po/fd8f8218d2ed331ad215edec1f793639 to your computer and use it in GitHub Desktop.
Zendesk FCM Cloud Function
import * as functions from 'firebase-functions'
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
export const pushUpdates = functions.https.onRequest((request, response) => {
const tokens = request.body.devices.map(d => d.identifier)
const payload = {
data: {
title: request.body.notification.title,
ticket_id: request.body.notification.ticket_id
}
}
return admin.messaging().sendToDevice(tokens, payload)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment