Repository navigation
fix(push): re-register the device token on opt-in (#746) - #760
Merged
Merged
Conversation
Contributor
posthog-ios Compliance ReportDate: 2026-08-11 10:41:28 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
Contributor
|
Reviews (1): Last reviewed commit: "fix(push): re-register the device token ..." | Re-trigger Greptile |
marandaneto
reviewed
Aug 10, 2026
marandaneto
approved these changes
Aug 10, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
approving to unblock but see comments
…ster-746 # Conflicts: # PostHogTests/PostHogPushNotificationTest.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The opt-in half of #746. After a logout
unregisterclears the stored push token,optIn()only restores consent and the notification observer. It never refetches the APNs token or re-registers the device, so a user who opts out and back in stays unsubscribed and Workflows can't deliver to them until the next app restart re-runs registration.Change
On
optIn(), whencapturePushNotificationSubscriptionsis enabled, the SDK now re-requests the APNs device token. The OS redelivers it to the (re-installed) subscription integration, which re-registers the device. A newPostHogPushNotificationSubscriptionIntegration.requestTokenRefreshhook encapsulates theregisterForRemoteNotifications()call (with the same app-context guardstart()uses) and is overridable in tests.Manual push mode (
capturePushNotificationSubscriptions = false) is unchanged: the host owns the token lifecycle, so opt-in does not auto-refetch.How tested
PostHogPushNotificationTest: opt-in re-requests the token when auto-capture is on, and does not when it's off.POST /api/push_subscriptions. With the refetch disabled, the same taps produced no re-register, confirming the fix is what re-arms push.Not in this PR
The unregister-DELETE-during-opt-out half of #746 is fixed separately in #759. This PR is independent and targets
main.🤖 Draft — opening for review; will un-draft after self-review.