简体   繁体   English

Android GCM多次发送推送通知

[英]Android GCM send push notification multiple times

I have a released application which is working fine. 我有一个已发布的应用程序,可以正常工作。 But now I would like to release a new version and I tested push notification before I upload it to the play store. 但是现在我想发布一个新版本,并在将推送通知上载到Play商店之前对其进行了测试。 In the app I register to GCM and the pushnotification id will be send to our backend. 在应用程序中,我注册到GCM,而pushnotification ID将发送到我们的后端。 When the user do something in the app or website the backend send a notification to the GCM and the GCM should send the notificaton to users device. 当用户在应用程序或网站中执行某项操作时,后端会向GCM发送通知,并且GCM应该将通知发送给用户设备。 BUT, the device got multiple times this notification. 但是,设备多次收到此通知。 I logged my GcmListenerService and I see that the onMessageReceived() method called after 2 minutes, and after 4 minutes and after 8 minutes and after 16 minutes, and after 32 minutes. 我记录了我的GcmListenerService,发现在2分钟之后,4分钟之后,8分钟之后,16分钟之后以及32分钟之后调用了onMessageReceived()方法。 So my application got the same notification multiple times. 因此,我的应用程序多次收到相同的通知。 Why? 为什么?

如果没有更多信息,我会怀疑您的服务器正在重新发送消息,而不是应用程序多次接收到消息。

As stated here , there are instances wherein the GCM engine might change the registration ID whenever it determines it need to. 如所陈述在这里 ,存在这样的情况,其中,每当它确定它需要将GCM发动机可能会改变的注册ID。 And this might happen at anytime without prior warning. 而且这可能在没有事先警告的情况下随时发生。 That's why you should always check if the last registration ID matches the one that is current. 因此,您应该始终检查最后一个注册ID是否与当前的ID匹配。 You may also refer with this link . 您也可以使用此链接进行引用。 Maybe your regid registered more times in your database. 也许您的regid在数据库中注册了更多次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM