mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
init push notifications when the service starts
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user