ekasetiawans / flutter_background_service

248 stars 161 forks source link

android.app.MissingForegroundServiceTypeException: Starting FGS #429

Open itssaklenkhan opened 1 month ago

itssaklenkhan commented 1 month ago

E/AndroidRuntime(31746): java.lang.RuntimeException: Unable to create service id.flutter.flutter_background_service.BackgroundService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{70f0a3 31746:com.project/u0a387} targetSDK=34

I am getting this exception for devices with SDK 34, but it's working fine for devices below SDK 34.

vivaan-vama commented 2 weeks ago

In android 14 / sdk=34

we need to provide extra detailed foreground service permission and service add

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" /> * replace remote_messaging with your reason of using the service

then add services related to the same

<service
            android:name="id.flutter.flutter_background_service.BackgroundService"
            android:foregroundServiceType="remoteMessaging"
            />

this should work.