Skip to content

refactor(android): suppress Bundle.get(String) deprecation warning#2552

Open
OS-ruimoreiramendes wants to merge 5 commits into
nextfrom
refactor/RMET-5239/replace-deprecated-bundle-get
Open

refactor(android): suppress Bundle.get(String) deprecation warning#2552
OS-ruimoreiramendes wants to merge 5 commits into
nextfrom
refactor/RMET-5239/replace-deprecated-bundle-get

Conversation

@OS-ruimoreiramendes

@OS-ruimoreiramendes OS-ruimoreiramendes commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Replace the deprecated Bundle.get(String) calls in push-notifications and local-notifications with a small helper that uses typed Bundle getters and BundleCompat.getParcelable / getSerializable as type-safe fallbacks.

Ref: https://outsystemsrd.atlassian.net/browse/RMET-5239

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

BaseBundle.get(String) has been deprecated since Android API 33. It was reintroduced in push-notifications and local-notifications by #2445 to allow non-String values in notification bundles, but Android does not provide a single type-safe replacement for "iterate over keys of unknown type", the recommended migration is to use type-specific accessors.

Tooltip from Android Studio
"This method was deprecated in API level 33. Use the type-safe specific APIs depending on the type of the item to be retrieved, eg. getString(String)."

Tests or Reproductions

Manually validated on a physical Android using capacitor-testapp.
Across all keys (extras such as android.title, android.text, android.progress, etc), the final JSON produced by the new helper matched the JSON produced by the deprecated bundle.get(key) path.

Platforms Affected

  • Android
  • iOS
  • Web

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Released dev build of push-notifications with dev version: 9.0.0-dev-2552-20260619T154839.0

@jcesarmobile jcesarmobile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the extractBundleValue method static? I don't think it needs to be.

@OS-ruimoreiramendes

Copy link
Copy Markdown
Contributor Author

why is the extractBundleValue method static? I don't think it needs to be.

yeah, no reason for it to be static. I likely added it during an earlier iteration and forgot to clean up

@jcesarmobile

Copy link
Copy Markdown
Member

I've been testing and it generates a ton of java.lang.ClassCastException warnings (one per key and per type check), while they are not crashes, I think they can scare/confuse users.

Maybe we should keep get despite it's deprecated and just silence it? I doubt google will remove it since there is no real alternative.

@OS-ruimoreiramendes

OS-ruimoreiramendes commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

I've been testing and it generates a ton of java.lang.ClassCastException warnings (one per key and per type check), while they are not crashes, I think they can scare/confuse users.

Maybe we should keep get despite it's deprecated and just silence it? I doubt google will remove it since there is no real alternative.

@jcesarmobile Hmm, I missed the warnings because my logcat filter was silencing everything outside my custom tag.
I'll simplify to a single bundle.get(key) and suppress the warning

@OS-ruimoreiramendes OS-ruimoreiramendes changed the title refactor(android): replace deprecated Bundle.get(String) refactor(android): suppress Bundle.get(String) deprecation warning Jun 19, 2026
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