Android API 34: Crash issue
Hi, I found this crash issue when I add this module in a new react-native project (Android API 34).
Unable to start service app.notifee.core.ForegroundService@a933913 with Intent { act=app.notifee.core.ForegroundService.START cmp=com.mywellnessconnect.patient/app.notifee.core.ForegroundService (has extras) }: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{e093e96 12327:com.mywellnessconnect.patient/u0a352} targetSDK=34
Do you know how to fix this crash? Or if we have a plan to upgrade this library, can you let me know the release time?
I have the exact same issue. The solution is supposed to be defining the services type in the android manifest inside of the application tag like this
<service
android:name="app.notifee.core.ForegroundService"
android:foregroundServiceType="dataSync" />
But when I try to build after doing that I get the issue
Class referenced in the manifest, app.notifee.core.ForegroundService, was not found in the project or the libraries [MissingClass]
android:name="app.notifee.core.ForegroundService"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As I investigated, the issue happens on Android API 34 so I made a fork here to fix it. Anyone who wants to have a result. Please follow my change here. Hope the package will be upgraded soon.
https://github.com/maidinhkhoa92/notifee/commit/0aa15c9b2591b9f7644c07c23fa5539345485621
Same issue on Android 14. @maidinhkhoa92 can you open PR for proposed changes, if they related and solve issue maybe @mikehardy can approve them? Thanks
The docs shows examples about declaring a foreground service type. You should be able to declare other FGS like dataSync.
If you use expo (managed workflow), I think the best way to edit the manifest is writing a plugin. You should also declare android.permission.FOREGROUND_SERVICE_DATA_SYNC in your app config. You can take a look at these changes: https://github.com/G-Ray/pikatorrent/commit/d044e1c5dac871193053c35872c03fd3192a598e
@pronevich This PR is the same with my changes https://github.com/invertase/notifee/pull/1050
Can you review it?
Google Play is requiring all apps to target 34 from next month and I just ran into this while upgrading our app.
Will this fix be in a forthcoming release?
Having crash's on production after the update required by google. Any news on this?
Adding the appropriate permissions in the 'AndroidManifest.xml' fixed the crashs for me:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
In my case, the app uses background_location, only necessary if you really need.
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
any news on this?
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
still make crash on this
<manifest>
...
<!-- For example, with one service type -->
<service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location" />
<!-- Or, with multiple service types -->
<service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location|camera|microphone" />
</manifest>
still make crash on this
@Logan-FE If you need a fixed version until the author updates, you can install my fork in here. https://www.npmjs.com/package/evizi-notifee
+1
In my case, I'm recording audio and I needed to add:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
And also check that the POST_NOTIFICATIONS permission has been granted before starting the Notifee service.
This has stopped the app crashing. Be great if the error was handled accordingly though if the required permissions aren't available.
I still used the old version 4.1.0 Here is a fork for fix the old version. https://www.npmjs.com/package/sx-notifee
this library is not maintained anymore?
i see a lot of forks but the PR fixing it not aprooved