在Strongloop中发送推送通知时,设备从安装中删除

Devices gets deleted from installation while sending push notification in Strongloop

本文关键字:安装 删除 通知 Strongloop      更新时间:2023-09-26

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

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

发生这种情况的所有场景是什么?

我的推送服务代码用于发送通知:

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

我能够找到问题:

当APN或GCM提供程序引发devicesGone事件时,相应的安装将被删除。请参阅环回组件推送包的push-manager.js。

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

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

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