Skip to content
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

ForegroundServiceStartNotAllowedException: Sometimes incoming call notification is not shown #1213

Open
Miara opened this issue Oct 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Miara
Copy link

Miara commented Oct 23, 2024

Business context
Before going to the production with GetStream SDK, I need to have some business proof that calls change will be beneficial for users. We have 2 major issues with old implementation. One with Samsung Fold (already reported here ) and this issue with foreground service notification.

Describe the bug
Sometimes, when the application is in the background, incoming call is not shown.

  • Notification is missing, because Foreground service is not started.
  • Foreground service is not started, because app is in the background
  • Foreground service cannot be started from the background when there are some battery saving restrictions set for the app.

It's hard to recreate these restrictions set in natural way, because even when battery optimization is enabled for the specific app, it doesn't mean that it always will throw Exception when trying to start foreground service from the background. You would have to use other apps, and then android system see that you need system resources for other apps, and put your app into deep sleep.

When there is no optimization enabled at all - this bug also appears, but very rarely and it's very hard to reproduce, however on production with many users it appears hundreds times per week.

However don't worry, I have some hacks below 😄

SDK version

  • 1.0.16

To Reproduce
Steps to reproduce the behavior:

  1. Log In to some test user Thierry in demo-app on deviceA, and go into the background
  2. Set background restrictions on deviceA using adb:
adb shell device_config put activity_manager \
   default_fgs_starts_restriction_notification_enabled true
  1. Go to the background on deviceA
  2. It looks like you don't catch exception in your SDK, because i don't see any error in logcat, so you can think about adding it, and meanwhile you can observe the error using:
adb logcat -T 1 | grep ActivityManager

In logcat
5. Log In to some test user Alex in demo-app on deviceB and call Thierry
6. There is no incoming push notification on deviceA

Expected behavior
Incoming push notification should appear on deviceA

Suggestion regarding solution
You could detect whether starting foreground service for incoming call crashes, and then you can use normal push notification (without foreground service), and after clicking on notification and opening the app, you could ensure that foreground service is started - if it wasn't started already.

Device:

  • Android version: Any device with Android >= 12
@Miara Miara added the bug Something isn't working label Oct 23, 2024
@aleksandar-apostolov
Copy link
Collaborator

Hi @Miara

Thanks for letting us know.
We will look into your suggestion about improving the notification handling.
On the other hand we are working on integrating the telecom framework which will handle this part with the service / notification.

Regards,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants