Skip to content

Instantly share code, notes, and snippets.

@Widcket
Created January 16, 2019 19:48
Show Gist options
  • Save Widcket/d2302171a8588f1382979b777752cdfd to your computer and use it in GitHub Desktop.
Save Widcket/d2302171a8588f1382979b777752cdfd to your computer and use it in GitHub Desktop.
Remote Config Cloud Function
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.pushConfig = functions.remoteConfig.onUpdate(metadata => {
const payload = {
data: {
CONFIG_STATE: 'STALE'
}
};
const options = {
content_available: true
};
// Use the Admin SDK to send the ping via FCM.
return admin
.messaging()
.sendToTopic('REMOTE_CONFIG', payload, options)
.then(response => {
console.log(response);
return null;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment