mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 20:49:36 +01:00
add PeriodicWorkRequest to register local token every 24h
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
06afd7bec6
commit
76cab3b9a0
@ -35,23 +35,6 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi
|
|||||||
override fun onProviderInstallFailed(p0: Int, p1: Intent?) {
|
override fun onProviderInstallFailed(p0: Int, p1: Intent?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUpPushTokenRegistration() {
|
|
||||||
val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java).build()
|
|
||||||
WorkManager.getInstance().enqueue(pushRegistrationWork)
|
|
||||||
|
|
||||||
val periodicPushRegistration = PeriodicWorkRequest.Builder(
|
|
||||||
GetFirebasePushTokenWorker::class.java, 15, // TODO: discuss intervall. joas 24h, google 1 month
|
|
||||||
TimeUnit.MINUTES
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
WorkManager.getInstance()
|
|
||||||
.enqueueUniquePeriodicWork(
|
|
||||||
"periodicPushRegistration", ExistingPeriodicWorkPolicy.REPLACE,
|
|
||||||
periodicPushRegistration
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isGPlayServicesAvailable() : Boolean {
|
private fun isGPlayServicesAvailable() : Boolean {
|
||||||
val api = GoogleApiAvailability.getInstance()
|
val api = GoogleApiAvailability.getInstance()
|
||||||
val code =
|
val code =
|
||||||
@ -62,4 +45,43 @@ class ClosedInterfaceImpl : ClosedInterface, ProviderInstaller.ProviderInstallLi
|
|||||||
}
|
}
|
||||||
return code == ConnectionResult.SUCCESS
|
return code == ConnectionResult.SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setUpPushTokenRegistration() {
|
||||||
|
registerLocalToken()
|
||||||
|
setUpPeriodicLocalTokenRegistration()
|
||||||
|
setUpPeriodicTokenRefreshFromFCM()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerLocalToken(){
|
||||||
|
val pushRegistrationWork = OneTimeWorkRequest.Builder(PushRegistrationWorker::class.java).build()
|
||||||
|
WorkManager.getInstance().enqueue(pushRegistrationWork)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPeriodicLocalTokenRegistration () {
|
||||||
|
val periodicTokenRegistration = PeriodicWorkRequest.Builder(
|
||||||
|
PushRegistrationWorker::class.java, 1,
|
||||||
|
TimeUnit.DAYS
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
WorkManager.getInstance()
|
||||||
|
.enqueueUniquePeriodicWork(
|
||||||
|
"periodicTokenRegistration", ExistingPeriodicWorkPolicy.REPLACE,
|
||||||
|
periodicTokenRegistration
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpPeriodicTokenRefreshFromFCM () {
|
||||||
|
val periodicTokenRefreshFromFCM = PeriodicWorkRequest.Builder(
|
||||||
|
GetFirebasePushTokenWorker::class.java, 30,
|
||||||
|
TimeUnit.DAYS
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
WorkManager.getInstance()
|
||||||
|
.enqueueUniquePeriodicWork(
|
||||||
|
"periodicTokenRefreshFromFCM", ExistingPeriodicWorkPolicy.REPLACE,
|
||||||
|
periodicTokenRefreshFromFCM
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user