A few fixes. 

function notifyUserId (id, payload) {
  core.emit("getUsers", { ref: id }, function(err, data) {
    notifyUser(data.results[0], payload);
  }
}

function notifyUser(user, payload) {
  if (userObj.params.pushNotifications && userObj.params.pushNotifications.devices) {
  devices = userObj.params.pushNotifications.devices;
  devices.forEach(function(device) {
  if (device.hasOwnProperty('registrationId') && device.enabled === true) {
  // send notification
  notify(payload, [device.registrationId]);
  }
  });
  }
}