Created
May 14, 2018 14:56
-
-
Save e2po/fd8f8218d2ed331ad215edec1f793639 to your computer and use it in GitHub Desktop.
Zendesk FCM Cloud Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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