apple push notifications - When one PushSharp message fails, they all fail -


i'm using push sharp library send push notifications apple apn server. code works great, can send 1000s of notifications.

the problem is, if attempt send notification invalid device token receive failure message push sharp framework pushsharp.apple.notificationfailureexception , every message queued after point not sent. basically, pushsharp clears queue if single notification fails.

for example, if queue 4 notifications (1,2,3,4) , notification 2 has invalid device token, notification 1 sent, 2 fail, , 3 , 4 not sent (and no event fired informing of this).

i understand notification invalid device token not sent not acceptable drop other n queued notifications on floor.

are there workarounds this?

here's code:

_applesettings = new applepushchannelsettings(!notification_service_use_development, notification_service_use_development ? ssl_certificate_name_dev : ssl_certificate_name_prod, ssl_certificate_password); _applesettings.connectiontimeout = notification_service_connection_timeout; _applesettings.feedbackintervalminutes = 0; /*we handle feedback externally*/ _applesettings.maxconnectionattempts = notification_service_retry_attemps;  _servicesettings = new pushservicesettings(); _servicesettings.maxautoscalechannels = notification_service_num_connections;  _pushbroker = new pushbroker(); _pushbroker.onchannelcreated += _pushbroker_onchannelcreated; _pushbroker.onchanneldestroyed += _pushbroker_onchanneldestroyed; _pushbroker.onchannelexception += _pushbroker_onchannelexception; _pushbroker.ondevicesubscriptionchanged += _pushbroker_ondevicesubscriptionchanged; _pushbroker.ondevicesubscriptionexpired += _pushbroker_ondevicesubscriptionexpired; _pushbroker.onnotificationfailed += _pushbroker_onnotificationfailed; _pushbroker.onnotificationrequeue += _pushbroker_onnotificationrequeue; _pushbroker.onnotificationsent += _pushbroker_onnotificationsent; _pushbroker.onserviceexception += _pushbroker_onserviceexception;   //now add settings push broker _pushbroker.registerappleservice(_applesettings, _servicesettings);   notification = new applenotification(notificationmessage.deviceextcontext); notification.payload.alert.body = notificationmessage.message; notification.payload.sound = notification_sound; // notification.payload.badge = 1; notification.tag = notificationmessage;  //attempt queue notification _pushbroker.queuenotification(notification); 

ok. this answer , this answer seem help.

like i've found in testing i'll onnotificationfailed event when have invalid device token, , every subsequent notice fail well.

short story seems apple silently drops connection on invalid device token, , follows fails (same error).

all not lost. in event handler onnotificationfailed, can check contents of notification that's passed in see ones have failed.

the next logical step walk them individually, re-sending same notification. pruning out ones second failure being invalid future notifications and/or marking ones succeed good.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -