Skip to content

iOS: $push_notification_opened not captured (warm or cold start) when flutter_local_notifications owns the notification delegate #555

Description

@jimnaylor

Summary

Push token registration works end to end (device token registers, Workflows pushes deliver via the APNs channel), but $push_notification_opened is never captured when the user taps a delivered push — on neither warm start (app backgrounded) nor cold start (app force-quit). Application Opened and the rest of the session capture normally, so it isn't a flush/ingestion issue: the open event simply never fires.

Environment

  • posthog_flutter 5.39.0 (native posthog-ios resolved via the podspec pin >= 3.70.0, < 4.0.0)
  • Flutter (stable), iOS device build distributed via TestFlight
  • flutter_local_notifications 22.x in the same app — it calls UNUserNotificationCenter.current().delegate = self during its initialize() (used for locally scheduled reminders)
  • PostHog config: defaults — enableSwizzling, capturePushNotificationSubscriptions, capturePushNotificationOpened all true; EU instance
  • Push sent through a PostHog Workflows function_push step over a connected APNs channel (so title/body should be attachable)

Repro

  1. App with both posthog_flutter 5.39.0 and flutter_local_notifications 22.x initialized (FLN sets the UNUserNotificationCenter delegate).
  2. Register device token via the automatic subscription path (works — token registers, $device_push_subscription_<bundle_id> person property appears).
  3. Send a push via a Workflows push step (delivery confirmed: "Push notification accepted by APNs" in workflow logs; notification arrives).
  4. Tap the notification — tested both with the app backgrounded and fully force-quit.

Expected: $push_notification_opened captured.
Actual: no $push_notification_opened ever appears (project-wide count is zero). Application Opened from the same tap session arrives normally.

Suspicion

Reading PushNotificationPublisher in posthog-ios, the swizzling covers both the delegate-setter and an already-set delegate's userNotificationCenter(_:didReceive:withCompletionHandler:), so the FLN pairing looks like it should be handled — but with FLN as the delegate the response never reaches the publisher in practice. The Flutter changelog for the push release notes that the manual capturePushNotificationOpened API exists for "paths auto-detection cannot see"; in this configuration that appears to be all paths.

Happy to test a fix or provide more detail (delegate setup order, timestamps, workflow/invocation IDs) if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions