Push notifications causing a crash when targeting Android API 31+

I am using the latest Backendless SDK v6.3.4 and targeting Android SDK 31. When the device receives a push notification message the following crash happens:

E/BackendlessFCMService: Error processing push notification
java.lang.IllegalArgumentException: org.helpapaw.helpapaw: 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:382)
at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465)
at android.app.PendingIntent.getActivity(PendingIntent.java:451)
at android.app.PendingIntent.getActivity(PendingIntent.java:415)
at com.backendless.push.BackendlessFCMService.fallBackMode(BackendlessFCMService.java:181)
at com.backendless.push.BackendlessFCMService.handleMessage(BackendlessFCMService.java:113)
at com.backendless.push.BackendlessFCMService.onMessageReceived(BackendlessFCMService.java:68)
at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@21.1.0:13)
at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@21.1.0:8)
at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@21.1.0:3)
at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@21.1.0:3)
at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@21.1.0:1)
at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.0.0:2)
at java.lang.Thread.run(Thread.java:920)

As the crash message says - PendingIntents on Android 31+ should have a mutability flag. The fix is rather easy - just add FLAG_IMMUTABLE in BackendlessFCMService.java:181
Hope this fill be fixed very soon!

Hi @milen-marinov

Thank you for discovering this problem, this will definitely make Backendless better.
I’ve created an internal ticket BKNDLSS-28122 to investigate this problem.

Regards,
Viktor

hello @milen-marinov

currently, backendless fully support API 28. We are on task to add support 29+. For API 29+ you can use push notifications, but in this case, you should create your own FirebaseMessagingService implementation.

Hello @sergey.kuk ,

Thanks for the clarification! Please let me know when the SDK with support for API 29+ is released. Also, is there any customization that shoud be made in the FirebaseMessagingService implementation and is it documented?

The internal ticket for the task is BKNDLSS-28887, we will notify you as soon as it will be implemented.

It is not documented but you just override onMessageReceived method, so just as standard google cloud messaging implementation

1 Like