0

I am trying to set up push notifications with strongloop. I don't understand which file the code below lives in. The docs don't say, which is confusing for newbies.

I understand that I have to add a push component to loopback restful api application, which I have done. But how do I reference the push component from my restful api app? Where's the 'glue'?

http://docs.strongloop.com/display/public/LB/Push+notifications

 var badge = 1;
    app.post('/notify/:id', function (req, res, next) {
     var note = new Notification({
       expirationInterval: 3600, // Expires 1 hour from now.
       badge: badge++,
       sound: 'ping.aiff',
       alert: '\uD83D\uDCE7 \u2709 ' + 'Hello',
       messageFrom: 'Ray'
     });

     PushModel.notifyById(req.params.id, note, function(err) {
       if (err) {
         // let the default error handling middleware
         // report the error in an appropriate way
         return next(err);
       }
       console.log('pushing notification to %j', req.params.id);
       res.send(200, 'OK');
     });
    });
Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55
user798719
  • 9,619
  • 25
  • 84
  • 123

1 Answers1

0

This should live in the app.js file as seen in the example here:

https://github.com/strongloop/loopback-component-push/blob/master/example/server/app.js#L137-L145

JSimonsen
  • 2,642
  • 1
  • 13
  • 13