Node push notification

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsNode push notification

This script uses a pre-configured push notification service to send notifications when new records are created.

// POST /api/v2/db/_table/todo triggers script
// This script runs AFTER records are written to the db.
// records are in array event.request.payload.resource.
var lodash = require("lodash");
var request = require("request");
if (event.request.payload.resource) {
    lodash._.each(event.request.payload.resource, function( record ) {
		var msg = {
			"Message": {
				"default": "A new Todo named '" + + "' was just created!"
			"Subject": "New Todo Created"
		// service name is 'push', push to SNS topic by name
		var result ="push/topic/642246745556:test_topic", msg);
		// output result to storage/logs/dreamfactory.log