iOS Push: Why Your DeviceToken Isn't the Same as Notification Permission
The cost of conflating authorization and APNs registration is a production outage where users see push enabled but nothing arrives. For any iOS app with an account system, the deviceToken-to-uid binding is the piece that can leak messages between accounts if the backend doesn't enforce uniqueness.
iOS remote push splits into two independent systems that many tutorials merge into one. `requestAuthorization` on UNUserNotificationCenter controls whether alerts, sounds, and badges appear; it never talks to APNs and never yields a deviceToken. `registerForRemoteNotifications` on UIApplication is the only call that reaches APNs, and it works even when the user denied notification permission. The result is that a denied user still produces a valid token, and push can still be delivered silently, but a normal notification is dropped outright when permission is off.
The article maps the four combinations of authorization and registration, then walks the lifecycle of the token: it changes on reinstall, device restore, and APNs rotation, so every `didRegister` callback must upload the current value. It also details the two payload paths: normal remote notifications require authorization and fire the UN delegate callbacks, while silent push (`content-available:1`) bypasses authorization but is rate-limited and often can't wake a force-quit app. The binding rules for a multi-account IM app follow one line: one deviceToken belongs to exactly one uid at a time. The backend must enforce that with a unique index and a new binding that overrides the old uid, because client-side unbind calls can fail. The article ends with a checklist for testing push before release.
The most common iOS push tutorial error, merging `requestAuthorization` and `registerForRemoteNotifications` into one step, is the root cause of most subsequent confusion; this article's separation makes every callback condition a logical consequence rather than a memorized rule.
The article's pitfall list reveals that the biggest production risk isn't Apple's behavior but developers deleting `registerForRemoteNotifications` from startup logic while leaving permissions on; the failure mode is silent and hard to detect.
Because client-side unbind calls are unreliable, the backend must own the token-to-uid mapping with a unique constraint and automatic override; otherwise a device switching accounts can receive the former account's messages.