init push notifications when the service starts

This commit is contained in:
greenart7c3
2024-07-03 13:09:44 -03:00
parent f45f08a17d
commit 95b06b736b
@@ -15,10 +15,15 @@ import com.greenart7c3.nostrsigner.ui.NotificationType
import com.vitorpamplona.ammolite.relays.RelayPool
import java.util.Timer
import java.util.TimerTask
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
class ConnectivityService : Service() {
private var isStarted = false
private val timer = Timer()
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
override fun onBind(intent: Intent): IBinder {
return null!!
@@ -47,6 +52,11 @@ class ConnectivityService : Service() {
isStarted = true
startForeground(1, createNotification())
scope.launch(Dispatchers.IO) {
PushNotificationUtils.hasInit = false
PushNotificationUtils.init(LocalPreferences.allSavedAccounts(this@ConnectivityService))
}
timer.schedule(
object : TimerTask() {
override fun run() {