Skip to content

Add method to reset notification payload data#1018

Closed
franco-zalamena-iterable wants to merge 1 commit intomasterfrom
feat/199-reset-notification-payload
Closed

Add method to reset notification payload data#1018
franco-zalamena-iterable wants to merge 1 commit intomasterfrom
feat/199-reset-notification-payload

Conversation

@franco-zalamena-iterable
Copy link
Copy Markdown
Contributor

@franco-zalamena-iterable franco-zalamena-iterable commented Apr 7, 2026

Summary

  • Add clearPayloadData() method to IterableApi
  • Allows users to reset notification payload after processing

Test plan

  • Set payload data via notification, call clearPayloadData(), verify getPayloadData() returns null
  • Verify normal notification payload flow still works

🤖 Generated with Claude Code

Allow users to reset/clear the notification payload data returned by
getPayloadData() after they have finished processing it. Fixes #199.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@franco-zalamena-iterable
Copy link
Copy Markdown
Contributor Author

PR Analysis

Problem: IterableApi.getInstance().getPayloadData() retains notification payload data indefinitely after a push notification is opened. There is no public API to reset it, so consumers cannot distinguish between "a notification was just opened" and "stale data from a previous notification" once they have finished processing it.

Ideal fix plan:

  • Add a public method to clear _payloadData (set it to null) so consumers can reset it after processing
  • Alternatively, the SDK could auto-clear payload data after it has been consumed (e.g., after the first getPayloadData() call or after onResume completes), but that would be a breaking behavioral change, so a manual clear method is the safer, non-breaking approach
  • Add a unit test that sets payload data, calls the new clear method, and asserts getPayloadData() returns null

What the PR did:

  • Added a public clearPayloadData() method that sets _payloadData = null
  • Added Javadoc explaining when to call it
  • No tests included (only a manual test plan in the PR description)

Assessment:

  • Root cause identified: yes -- the field is set on notification open and never cleared, with no public API to reset it
  • Fix correctness: correct -- a public nulling method is the minimal, non-breaking solution; naming (clearPayloadData) is consistent with common Android SDK conventions
  • Missed: unit tests -- a simple test (set bundle via the package-private setPayloadData, call clearPayloadData, assert getPayloadData() is null) should be straightforward and would prevent regressions. The PR lists manual test steps but does not add automated tests.
  • Wrong assessment: none
  • Tests: needed but missing

@franco-zalamena-iterable franco-zalamena-iterable deleted the feat/199-reset-notification-payload branch April 8, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant