Push notification 按下按钮:一次又一次地发送相同的消息

Push notification 按下按钮:一次又一次地发送相同的消息,push-notification,pushsharp,Push Notification,Pushsharp,我是个新手。 我正在尝试使用Push Sharp向Android设备发送消息。它工作得很好,但问题是Push Sharp一次又一次地发送相同的信息 我的代码是: AndroidPushBroker = new PushBroker(); var googleKey = CustomConfigurationManager.GetValueFromSection("appSettings", "GoogleServerAccessKey"); AndroidPushBro

我是个新手。 我正在尝试使用Push Sharp向Android设备发送消息。它工作得很好,但问题是Push Sharp一次又一次地发送相同的信息

我的代码是:

AndroidPushBroker = new PushBroker();

var googleKey = CustomConfigurationManager.GetValueFromSection("appSettings", "GoogleServerAccessKey");
            AndroidPushBroker.RegisterGcmService(new PushSharp.Android.GcmPushChannelSettings(googleKey));

            var jsonMessage = "{\"InformationId\":\"" + notification.Message + "\",\"badge\":7,\"sound\":\"sound.caf\",\"NotificationType\":\"" + notification.Type.ToString() + "\"}";

            GcmNotification androidNotifcation = new GcmNotification().ForDeviceRegistrationId(notification.DeviceId)
                .WithJson(jsonMessage);
            AndroidPushBroker.QueueNotification(androidNotifcation);
问题:当我发送消息“消息1”,然后再发送“消息2”时,它会再次发送“消息1”。是否需要从队列中删除项目?或者我错过了什么


注意:我的应用程序中只有一个推送代理实例

我对PushSharp也不是很有经验,但我猜您在发送消息后没有清空通知队列

尝试在队列通知调用后添加以下内容

AndroidPushBroker.StopAllServices();
我终于明白了这个问题。 我一次又一次地注册我的gcm服务,这导致了重复事件

AndroidPushBroker.registergcmsservice(新的PushSharp.Android.GcmPushChannelSettings(googleKey))


这应该只调用一次。

谢谢frmi,但这不是问题所在。我终于解决了这个问题。