I would like to call a function with a api method to @Post
some information like registered token from notifications (FCM).
When application will be killed it also should be triggered.
What is the best way to achieve this feature and could I use somehow notification service to make it or should I make another service like in this example below.
Android: keep Service running when app is killed
Edit 1:
fun autoConsumingSendingToken() {
Log.d("tokenworker", "5 AUTOCONSUMING MAINACTIVITY")
val myWorkRequest: WorkRequest =
PeriodicWorkRequestBuilder<AutoTokenWorker>(20, TimeUnit.SECONDS).build()
WorkManager
.getInstance(applicationContext)
.enqueue(myWorkRequest)
}