Skip to content

fix(android): notification Bundles with non-string values#2445

Merged
OS-pedrogustavobilro merged 4 commits intoionic-team:mainfrom
frederikbosch:patch-1
Feb 25, 2026
Merged

fix(android): notification Bundles with non-string values#2445
OS-pedrogustavobilro merged 4 commits intoionic-team:mainfrom
frederikbosch:patch-1

Conversation

@frederikbosch
Copy link
Contributor

The method getDeliveredNotifications() throws because getString(key) is called on notification.extras but the extras Bundle object contains more than just strings. Booleans cannot be casted to string, see the exception stack trace below.

Key android.progressIndeterminate expected String but value was a java.lang.Boolean.  The default value <null> was returned. 
Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at android.os.BaseBundle.getString(BaseBundle.java:1448)
        at com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin.getDeliveredNotifications(PushNotificationsPlugin.java:147)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:837)
        at com.getcapacitor.Bridge.$r8$lambda$FNYM7cvgeBk0k8YXQH7M96Mrf-c(Unknown Source:0)
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
        at android.os.Handler.handleCallback(Handler.java:995)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loopOnce(Looper.java:273)
        at android.os.Looper.loop(Looper.java:363)
        at android.os.HandlerThread.run(HandlerThread.java:85)

The method `getDeliveredNotifications()` throws because `getString(key)` is called on `notification.extras` but the `extras` [`Bundle`](https://developer.android.com/reference/android/os/Bundle) object contains more than just strings.
@OS-pedrogustavobilro OS-pedrogustavobilro changed the title notification.extras also contains non-string values fix(push-notifications): notification.extras with non-string values on Android Feb 24, 2026
@OS-pedrogustavobilro OS-pedrogustavobilro changed the title fix(push-notifications): notification.extras with non-string values on Android fix(android): notification Bundles with non-string values Feb 24, 2026
@OS-pedrogustavobilro
Copy link
Contributor

Hey @frederikbosch thanks for the PR, I took the liberty of replicating the same change in local-notifications plugin.

I wasn't able to trigger a notification with non-string values, but can force-replicate the error in code, and since the data/extra types in the plugin API is any, I see no reason not to merge the PR.

@frederikbosch
Copy link
Contributor Author

@OS-pedrogustavobilro Sure, go ahead and replicate in local notifications.

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit 2788f81 into ionic-team:main Feb 25, 2026
12 of 14 checks passed
OS-pedrogustavobilro added a commit that referenced this pull request Feb 25, 2026
Co-authored-by: Pedro Bilro <pedro.gustavo.bilro@outsystems.com>
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.

PushNotification fails in newIntent getting String with ClassCastException

2 participants