question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: startForegroundService() not allowed due to mAllowStartForeground false

See original GitHub issue

Everything works fine when the app activity is running (in foreground or background).

But when the app is killed, the app starts in headless mode and then fires the notification as a Foreground Service. In this scenario, the notification does not show and notifee throws this error:

Error: startForegroundService() not allowed due to mAllowStartForeground false: service app.notifee.core.ForegroundService
    at Object.promiseMethodWrapper [as displayNotification] (NativeModules.js:106:51)
    at NotifeeApiModule._this.displayNotification (NotifeeApiModule.js:265:32)

If I set asForegroundService to false, the notification will show but without any styling.

I am on latest notifee version 5.4.1.

This is definitely related to Android 12 and the new Foreground Service restrictions imposed on apps, but according to this, my case should be exempt from these restrictions, since my app meets this exception Your app receives a high priority message using FCM.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mikehardycommented, Jul 19, 2022

Any java code imported in the app’s symbol space is available as an API, you can just call things I think

0reactions
github-actions[bot]commented, Dec 11, 2022

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception: startForegroundService() not allowed due to ...
When the application is closed or when the application went to the background, invoking Service using startForegroundService will cause ...
Read more >
SDK31 Android12 can't executing services on background ...
Fatal Android 12: Exception: startForegroundService() not allowed due to mAllowStartForeground false. I noticed one exception (Firebase ...
Read more >
Foreground services - Android Developers
startForegroundService() to start a foreground service that another app owns ... If the message's priority is downgraded, your app is not allowed to...
Read more >
Solved - appsloveworld
[Solved]-Caused by android.app.ForegroundServiceStartNotAllowedException startForegroundService() not allowed due to mAllowStartForeground false-kotlin.
Read more >
r/androiddev - Reddit
startForeground() not allowed due to mAllowStartForeground false: ... setServiceForeground(IActivityManager.java:7194) at android.app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found