mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3636 Notifications | Firebase messaging service implementation (#2383)
This commit is contained in:
parent
0e9a997998
commit
01638ff2f7
26 changed files with 273 additions and 10 deletions
|
@ -64,4 +64,6 @@ interface AuthRepository {
|
|||
suspend fun getNetworkMode(): NetworkModeConfig
|
||||
suspend fun setNetworkMode(modeConfig: NetworkModeConfig)
|
||||
suspend fun debugExportLogs(dir: String): String
|
||||
|
||||
suspend fun registerDeviceToken(command: Command.RegisterDeviceToken)
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.anytypeio.anytype.domain.device
|
||||
|
||||
interface DeviceTokenStoringService {
|
||||
fun saveToken(token: String)
|
||||
fun start()
|
||||
fun stop()
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.anytypeio.anytype.domain.notifications
|
||||
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.base.ResultInteractor
|
||||
import javax.inject.Inject
|
||||
|
||||
class RegisterDeviceToken @Inject constructor(
|
||||
private val repository: AuthRepository,
|
||||
dispatchers: AppCoroutineDispatchers
|
||||
) : ResultInteractor<RegisterDeviceToken.Params, Unit>(dispatchers.io) {
|
||||
|
||||
override suspend fun doWork(params: Params) {
|
||||
val command = Command.RegisterDeviceToken(
|
||||
token = params.token,
|
||||
)
|
||||
repository.registerDeviceToken(command = command)
|
||||
}
|
||||
|
||||
data class Params(
|
||||
val token: String
|
||||
)
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.anytypeio.anytype.domain.subscriptions
|
||||
|
||||
import com.anytypeio.anytype.domain.device.DeviceTokenStoringService
|
||||
import com.anytypeio.anytype.domain.device.NetworkConnectionStatus
|
||||
import com.anytypeio.anytype.domain.multiplayer.UserPermissionProvider
|
||||
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||
|
@ -19,7 +20,8 @@ interface GlobalSubscriptionManager {
|
|||
private val permissions: UserPermissionProvider,
|
||||
private val isSpaceDeleted: SpaceDeletedStatusWatcher,
|
||||
private val profile: ProfileSubscriptionManager,
|
||||
private val networkConnectionStatus: NetworkConnectionStatus
|
||||
private val networkConnectionStatus: NetworkConnectionStatus,
|
||||
private val deviceTokenStoringService: DeviceTokenStoringService
|
||||
) : GlobalSubscriptionManager {
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -29,6 +31,7 @@ interface GlobalSubscriptionManager {
|
|||
isSpaceDeleted.onStart()
|
||||
profile.onStart()
|
||||
networkConnectionStatus.start()
|
||||
deviceTokenStoringService.start()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -38,6 +41,7 @@ interface GlobalSubscriptionManager {
|
|||
isSpaceDeleted.onStop()
|
||||
profile.onStop()
|
||||
networkConnectionStatus.stop()
|
||||
deviceTokenStoringService.stop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue