Skip to content

[Bug] Android postNotification might crashes the app with exceptions #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlexV525 opened this issue Apr 11, 2025 · 5 comments
Open

Comments

@AlexV525
Copy link

AlexV525 commented Apr 11, 2025

We've received a couple of crashes caused by the post notification action on specific XiaoMi devices. I'm trying to figure out the root cause.

Version Info

Flutter: 3.27.4
connectycube_flutter_call_kit: 2.8.0
Device: Xiaomi Civi (Android 12)

Fatal Exception: java.lang.IllegalArgumentException: 0|com.example|-1003350140|null|10379 Not posted. CallStyle notifications must either be for a foreground Service or use a fullScreenIntent.
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2429)
       at android.os.Parcel.createException(Parcel.java:2409)
       at android.os.Parcel.readException(Parcel.java:2392)
       at android.os.Parcel.readException(Parcel.java:2334)
       at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:3416)
       at android.app.NotificationManager.notifyAsUser(NotificationManager.java:677)
       at android.app.NotificationManager.notify(NotificationManager.java:627)
       at androidx.core.app.NotificationManagerCompat.notify(NotificationManagerCompat.java:94)
       at androidx.core.app.NotificationManagerCompat.notify(NotificationManagerCompat.java:94)
       at com.connectycube.flutter.connectycube_flutter_call_kit.NotificationsManagerKt.postNotification(NotificationsManager.kt:94)
       at com.connectycube.flutter.connectycube_flutter_call_kit.NotificationsManagerKt$loadPhotoAndPostNotification$1.invokeSuspend(NotificationsManager.kt:122)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:11)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
       at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:19)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:3)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:96)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:96)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:96)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:96)

Permissions (part of) in our AndroidManifest.xml:

    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Exceptions will cause the app to crash. An expected behavior is not crashing the app and reporting the exception in the channel result.

@AlexV525 AlexV525 changed the title [Bug] Android IllegalArgumentException on specific XiaoMi devices [Bug] Android IllegalArgumentException on specific devices crashes the app Apr 11, 2025
@CubeRomanMagellan
Copy link
Contributor

It's hard to say for sure, because of specific device issue. But here are some thoughts.
As exception states CallStyle notifications must either be for a foreground Service or use a fullScreenIntent.
There is canUseFullScreenIntent option to check the permission, as one of the option.
Also, check in your AndroidManifest.xml
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

@AlexV525
Copy link
Author

AlexV525 commented Apr 11, 2025

Could we catch this exception without crashing the app?

@AlexV525
Copy link
Author

As exception states CallStyle notifications must either be for a foreground Service or use a fullScreenIntent. There is canUseFullScreenIntent option to check the permission, as one of the option.

Sure, but it's Android 12, which is confusing.

Also, check in your AndroidManifest.xml <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

We have microphone and media foreground services. call is restricted for apps other than clocks and phone call managers, so we didn't specify that.

@AlexV525
Copy link
Author

As for the exception, it went away after the user changed the sound of that notification channel. What a surprise...

@AlexV525 AlexV525 changed the title [Bug] Android IllegalArgumentException on specific devices crashes the app [Bug] Android postNotification might crashes the app with exceptions Apr 12, 2025
@CubeRomanMagellan
Copy link
Contributor

It's really surprising. Glad, the issue is gone for now.

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

No branches or pull requests

2 participants