Not working with .Net 8.0
Opened this issue ยท 4 comments
When targeting .Net 8.0, this exception is raised when calling
StartForeground(myId, notification.Build());
Exception :
Android.App.MissingForegroundServiceTypeException Message=Starting FGS without a type callerApp=
Clues :
https://developer.android.com/about/versions/14/changes/fgs-types-required#permission-for-fgs-type
Thank you for your excellent project Carl.
I found that putting a tag in the service attribute solve the problem :
[Service(ForegroundServiceType = global::Android.Content.PM.ForegroundService.TypeLocation)]
internal class MyBackgroundService : Service
Thanks to this link :
https://stackoverflow.com/questions/77520968/why-am-i-encountering-the-error-starting-fgs-without-a-type-when-executing-the
After using [Service(ForegroundServiceType = global::Android.Content.PM.ForegroundService.TypeLocation)] tag I am getting following error:
Java.Lang.SecurityException: 'Starting FGS with type location callerApp=ProcessRecord{f589edd 23148:---} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION,
What is the solution?
I don't receive any notification too. What should be done to correct this. Thank you.
Edit:
I just find the solution in this thread : https://stackoverflow.com/questions/76257122/how-to-send-notification-from-a-worker-in-android-13-maui-android/76258994#76258994