【问题标题】:From which file do I send a push notification in strongloop?我在strongloop中从哪个文件发送推送通知?
【发布时间】: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


    【解决方案1】:

    这应该存在于 app.js 文件中,如此处的示例所示:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多