Last active
September 29, 2021 18:29
-
-
Save maxirosson/2ba20f3c06bd9a6e3d2e656e009bf4e1 to your computer and use it in GitHub Desktop.
Firebase Cloud Function to send an FCM ping on Remote Config events
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
const functions = require("firebase-functions"); | |
const admin = require("firebase-admin"); | |
admin.initializeApp(); | |
exports.pushConfig = functions.remoteConfig.onUpdate((versionMetadata) => { | |
// Create FCM payload to send data message to REMOTE_CONFIG_PUSH topic. | |
const payload = { | |
topic: "REMOTE_CONFIG_PUSH", | |
data: { | |
"REMOTE_CONFIG_STATUS": "STALE", | |
}, | |
fcm_options: { | |
"analytics_label": "REMOTE_CONFIG_PUSH", | |
}, | |
}; | |
// Use the Admin SDK to send the ping via FCM. | |
return admin.messaging().send(payload).then((resp) => { | |
console.log(resp); | |
return null; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment