Skip to content

[Android] Deliver the tapped local notification's own payload#922

Open
aryajur wants to merge 1 commit into
coronalabs:masterfrom
aryajur:fix/android-notification-payload-in-intent
Open

[Android] Deliver the tapped local notification's own payload#922
aryajur wants to merge 1 commit into
coronalabs:masterfrom
aryajur:fix/android-notification-payload-in-intent

Conversation

@aryajur

@aryajur aryajur commented Jun 3, 2026

Copy link
Copy Markdown

On Android, tapping a local notification reconstructs its payload by looking the notification's integer id up in the mutable, id-keyed getCacheDir()/.system/NotificationSettings.xml file. Because ids are recycled (reserveId() probes from 1 and frees ids on cancel) and apps commonly cancelAll+reschedule daily, a reused id's entry gets overwritten, so a stale status-bar item taps through to a DIFFERENT notification's content. The sibling failure is #915: when the OS purges the cache the lookup returns null and launchArgs.notification is nil.

Fix: embed the full payload in the tap content intent at post time (reusing NotificationReceivedTask.toBundle()) and prefer it on tap, falling back to the by-id lookup for notifications posted by an older runtime. Add FLAG_UPDATE_CURRENT to the content PendingIntent so a reused id refreshes its embedded payload instead of aliasing the previous one's. The tapped notification now delivers exactly what was posted, regardless of id reuse or cache eviction (also resolves #915).

On Android, tapping a local notification reconstructs its payload by
looking the notification's integer id up in the mutable, id-keyed
getCacheDir()/.system/NotificationSettings.xml file. Because ids are
recycled (reserveId() probes from 1 and frees ids on cancel) and apps
commonly cancelAll+reschedule daily, a reused id's entry gets overwritten,
so a stale status-bar item taps through to a DIFFERENT notification's
content. The sibling failure is coronalabs#915: when the OS purges the cache the
lookup returns null and launchArgs.notification is nil.

Fix: embed the full payload in the tap content intent at post time
(reusing NotificationReceivedTask.toBundle()) and prefer it on tap,
falling back to the by-id lookup for notifications posted by an older
runtime. Add FLAG_UPDATE_CURRENT to the content PendingIntent so a reused
id refreshes its embedded payload instead of aliasing the previous one's.
The tapped notification now delivers exactly what was posted, regardless
of id reuse or cache eviction (also resolves coronalabs#915).
@aryajur aryajur requested a review from Shchvova as a code owner June 3, 2026 05:32
@CLAassistant

CLAassistant commented Jun 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Android]: Notification plugin context lost - runtime bug

2 participants