New phone, old push token: why retrying never works
transcript
Your app sends a payment alert. The push fails. So you retry. It fails again. And it will fail every single time.
Here's why. A push goes to a device token. And tokens change. The user reinstalls your app. Or restores onto a new phone. Or just updates the OS. Your database still holds the old token.
The push comes back: invalid token. You retry. Same failure. Again and again. Wasted work. And the user never gets the alert. The production answer: detect that response, and mark the token invalid. Then route the alert to a fallback. Email, or SMS.
Follow one alert. It goes to the old token, and comes back invalid. Mark it invalid in the database, so nobody tries it again. Send it by email or SMS instead. The alert still lands. Next time the app opens, it registers a new token. A background job clears the stale ones.
But here's the catch. Should this trip the provider's circuit breaker? No. It's one bad token, not a failing provider. A breaker is the wrong tool.
A dead token never comes back to life. Retrying just repeats the failure. Mark it dead. Reach the user another way.
Full breakdown in the lecture.