2015-05-14 35 views
0

我想用strongloop設置推送通知。我不明白下面的代碼在哪個文件中。文檔沒有說,這對於新手來說是令人困惑的。從哪個文件我可以通過strongloop發送推送通知?

據我所知,我必須添加一個推送組件到loopback restful API應用程序,我已經完成了。但是,我如何從我的restful api應用程序中引用推送組件? '膠水'在哪裏?

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'); 
    }); 
    }); 

回答