I’m using a C# Windows Service to send notifications to the APNs. It is working just fine. However, today I received an error 8 from Apple (Invalid token).
I added code to handle this case (removing the token from the db so that I don’t send any more notifications). However, as Apple says, I’m sending a batch of notifications through the same channel… and those are sent on the same connection (I don’t know that it failed until they return the response), but I’m seeing that the other notifications are not being delivered.
Is this something normal? how do you deal with this? I was thinking to store all the notifications and, after sending all of them, wait for 5 seconds… if Apple didn’t send any notifications, it’s all good… if something happens, check the error, remove the failed notifications and send the remaining ones until no error is received.
Does this make sense?
Thanks!
That is exactly what we ended up doing in JavaPNS. A list of notifications is pushed, an error-response packet is received for a specific notification in that list, the library restarts sending notifications using the same list but starting at the notification after the one that failed. Loop until no error-response packets are received.
This does mean that you will be streaming a lot of notifications over and over again, if you have multiple invalid messages in your list… but from experience, it seems that this is the only way to work successfully with APNS.