Skip to content

Push: opt-out during an in-flight unregister can strand the DELETE, and opting back in never re-registers the token #746

Closed

Description

@ioannisj

Problem

unregister persists its PendingUnregister and then defers on guard isAllowedProvider() when the SDK is disabled or opted out, and it re-checks consent again after the asynchronous identity-token mint. So unregisterPushNotificationToken() followed closely by opt-out, the standard shape of a host app's opt-out flow, can park the DELETE: the pending record survives, but the same consent gates keep deferring it on every retry while opted out. The server-side subscription stays active for the whole opted-out period and Workflows keep delivering to a device that opted out.

On the way back: a successful DELETE clears the stored token, and opting back in only restores consent and the observer, it doesn't refetch the APNs token or re-register. Push stays dead until the next app restart re-runs registration.

Found while reviewing the React Native push integration (PostHog/posthog-js#4415, thread): the wrapper orders its bridge calls (unregister before opt-out) but that can't order the handler's internal async work, so the fix has to live here.

Proposal

  • Allow a pending unregister to execute while opted out: a DELETE is data removal, not collection, so the opt-out gate should block registration and sends but not cleanup.
  • On opt-in with capturePushNotificationSubscriptions enabled, refetch the token and re-register, so opting back in re-arms push without an app restart.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions