【问题标题】:Devices gets deleted from installation while sending push notification in Strongloop在 Strongloop 中发送推送通知时,设备从安装中删除
【发布时间】:2017-03-06 03:07:30
【问题描述】:

我是 strongloop 的新手,我为 android 实现了推送通知。

在一段时间内一切正常,然后设备开始从数据库中的安装集合中消失,同时发送通知。我不知道为什么会这样,请帮助我解决这个问题。

在哪些情况下会发生这种情况?

我用于发送通知的 pushService 代码:

 exports.sendPush = function (appObject,deviceId,type,userId,incomingMessage)  {
      var PushModel = appObject.models.push;
      var androidNotification = appObject.models.notification;

      // to avoid event emitter memory leak
      pushModel.removeAllListeners('error'); 

      var note = new androidNotification({
        message: incomingMessage,
        deviceId: deviceId,
        type: type
      });

      pushModel.notifyByQuery({userId: userId,deviceType:"android"}, note, function(err) {
             if(err)
              {
                console.log('android : pushing notification failed to %j', userId);
              }
             else
             {
                console.log('android : pushing notification to %j', userId);
                console.log('android note : ',note);
             }
         });

      pushModel.on('error', function (err) {
         console.error('Push Notification error: ', err.stack);
      });
};

【问题讨论】:

  • 我也有同样的问题。
  • @mnesarco 的任何解决方案?
  • 很抱歉@ilir-aga 我不再使用 StrongLoop。

标签: javascript strongloop


【解决方案1】:

我找到了问题:

当 APNs 或 GCM 提供程序引发 devicesGone-event 时,相应的安装将被删除。参见 loopback-component-push 包的 push-manager.js。

在我的情况下,应用程序设置为 production=false,但处于生产模式 (TestFlight)。

要停止这种方法,你的安装模型的destroyAll必须被钩住和覆盖:

看这里,我的安装模型叫做 Participanz http://pastebin.com/aaed22dZ

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    • 2017-12-07
    • 2019-10-13
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多