【发布时间】:2015-06-12 02:01:02
【问题描述】:
我正在尝试使用 strongloop 设置推送通知。我不明白下面的代码存在于哪个文件中。文档没有说,这让新手感到困惑。
我知道我必须向环回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');
});
});
【问题讨论】:
标签: push-notification loopbackjs strongloop