[Android] Deliver the tapped local notification's own payload#922
Open
aryajur wants to merge 1 commit into
Open
[Android] Deliver the tapped local notification's own payload#922aryajur wants to merge 1 commit into
aryajur wants to merge 1 commit into
Conversation
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).
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.
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).