Local Notifications ScheduleOn functionality causes App to crash

Hi everyone,

I’ve recently upgraded my project from Capacitor 3 to 4 in hopes to comply to the new Google playstore API level requirements. I’m building an Android app that uses the Local Notifications plugin, however I’ve discovered that when using the ScheduleOn functionality with “cron”-styled scheduling, my app crashes upon delivery of the notification.

I get the following error:

java.lang.RuntimeException: Unable to start receiver com.capacitorjs.plugins.localnotifications.TimedNotificationPublisher: java.lang.IllegalArgumentException: io.ionic.starter: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

I saw a github issue regarding this and it mentions it has been solved in Capacitor 4.0 release so I am rather confused if I had done anything wrong with the migration. I did it with the CLI and there were no errors. I’ve also verified that my files correspond to the ones on the Cap 4 blogpost.

Could it be an isolated issue with ScheduleOn? Because I’ve also tested with scheduling at a later date/time with { at } and it works fine.

1 Like