Foreground service

i need to create a foreground service for an android app (capacitor4, ionic 6).
Following the official android guide i managed to create it working directly on the native android project (editing the mainactivity and androidmanifest files and defining the service class inside the project).
I am now struggling to port the code i wrote inside a plugin.
I am facing some issues: code working in the android project does not work inside the plugin, directives added to the app androidmanifest seem not working if added to the plugin android manifest.
Is there any documentation, or sample i could look at?

thank you