|
|
|
@ -19,10 +19,11 @@ package com.google.samples.apps.nowinandroid.sync.services
|
|
|
|
|
import com.google.firebase.messaging.FirebaseMessagingService
|
|
|
|
|
import com.google.firebase.messaging.RemoteMessage
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.data.util.SyncManager
|
|
|
|
|
import com.google.samples.apps.nowinandroid.sync.initializers.SYNC_TOPIC
|
|
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
|
|
private const val SYNC_TOPIC_SENDER = "/topics/sync"
|
|
|
|
|
|
|
|
|
|
@AndroidEntryPoint
|
|
|
|
|
class SyncNotificationsService : FirebaseMessagingService() {
|
|
|
|
|
|
|
|
|
@ -30,7 +31,7 @@ class SyncNotificationsService : FirebaseMessagingService() {
|
|
|
|
|
lateinit var syncManager: SyncManager
|
|
|
|
|
|
|
|
|
|
override fun onMessageReceived(message: RemoteMessage) {
|
|
|
|
|
if (SYNC_TOPIC == message.from) {
|
|
|
|
|
if (SYNC_TOPIC_SENDER == message.from) {
|
|
|
|
|
syncManager.requestSync()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|