Skip to content

Conversation

@sumeruchat
Copy link
Collaborator

@sumeruchat sumeruchat commented Jan 16, 2026

What

Fixes custom actions not working when SDK is not initialized and openApp=false. This enables "snooze" type push notification flows where a button action can trigger a journey without opening the app.

Jira ticket: SDK-307

Changes

  • Store application context early in handlePushAction() so getMainActivityContext() returns non-null even before initialize() is called
  • Only clear pendingAction if the action was actually handled, allowing deferred processing when SDK is initialized later with a customActionHandler

Impact

  • Breaking changes: None
  • Dependencies: None
  • Performance: No impact

Testing

How to test:

  1. Set up a push notification with an action button that has openApp=false and a custom action type
  2. Receive the push while the app is backgrounded/not initialized
  3. Tap the action button
  4. Verify the custom action handler is called (either immediately if context is available, or when SDK initializes)

Unit tests added:

  • testBackgroundCustomActionWithNonInitializedSDK - verifies context is stored even without SDK init
  • testBackgroundCustomActionProcessedAfterSDKInit - verifies pending actions are processed after initialization

When a push action with openApp=false is received before SDK initialization,
the custom action handler was never invoked because getMainActivityContext()
returned null.

This fix:
1. Stores the application context early in handlePushAction() so
   getMainActivityContext() returns non-null even before initialize() is called
2. Only clears pendingAction if the action was actually handled, allowing
   deferred processing when SDK is initialized later with a customActionHandler

This enables "snooze" type flows where a push button action with openApp=false
can trigger a journey without requiring the full app to open.
@sumeruchat sumeruchat changed the title Fix custom actions not working in background when SDK is not initialized SDK-307 Fix custom actions not working in background when SDK is not initialized Jan 16, 2026
@sumeruchat sumeruchat closed this Jan 16, 2026
@sumeruchat sumeruchat deleted the claude/fix-background-custom-actions-ysoRP branch January 16, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants