ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
518 stars 583 forks source link

bug(local-notifications) Targeting SDK 31 requires that one of FLAG_IMMUTABLE must be specified #772

Closed Houdhey closed 2 years ago

Houdhey commented 2 years ago

Bug Report

Plugin(s)

local-notifications

Capacitor Version

3.3.1

Platform(s)

Android

Current Behavior

Schedule a local notification for Android 12

Expected Behavior

Do not crash the app

Other Technical Details

2022-01-19 15:35:47.214 18007-18178/luE/Capacitor: Serious error executing plugin
    java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
        at com.getcapacitor.Bridge$1.run(Bridge.java:520)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.IllegalArgumentException: lu.lalux.easyapp.android: 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.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at com.getcapacitor.plugin.notification.LocalNotificationManager.cancelTimerForNotification(LocalNotificationManager.java:355)
        at com.getcapacitor.plugin.notification.LocalNotificationManager.schedule(LocalNotificationManager.java:149)
        at com.getcapacitor.plugin.LocalNotifications.schedule(LocalNotifications.java:75)
            ... 8 more
2022-01-19 15:35:47.364 18007-18178/ E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
    Process: lu.lalux.easyapp.android, PID: 18007
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.getcapacitor.Bridge$1.run(Bridge.java:529)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
        at com.getcapacitor.Bridge$1.run(Bridge.java:520)
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: java.lang.IllegalArgumentException: 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.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at com.getcapacitor.plugin.notification.LocalNotificationManager.cancelTimerForNotification(LocalNotificationManager.java:355)
        at com.getcapacitor.plugin.notification.LocalNotificationManager.schedule(LocalNotificationManager.java:149)
        at com.getcapacitor.plugin.LocalNotifications.schedule(LocalNotifications.java:75)
            ... 8 more
jcesarmobile commented 2 years ago

thanks for the issue, but it's already reported on https://github.com/ionic-team/capacitor-plugins/issues/689

note that for supporting Android 12 devices you don't need to target SDK 31, we will target SDK 31 on Capacitor 4 and we will do a major version bump on all plugins too fixing all issues that appear when targeting SDK 31.

ionitron-bot[bot] commented 2 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.