-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
146 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
data/src/main/java/com/dkin/chevit/data/di/FirebaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.dkin.chevit.data.di | ||
|
||
import com.google.firebase.messaging.FirebaseMessaging | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class FirebaseModule { | ||
@Singleton | ||
@Provides | ||
fun provideFirebaseMessage(): FirebaseMessaging { | ||
return FirebaseMessaging.getInstance() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../main/java/com/dkin/chevit/domain/usecase/notification/SyncFirebaseMessageTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.dkin.chevit.domain.usecase.notification | ||
|
||
import com.dkin.chevit.domain.base.CoroutineDispatcherProvider | ||
import com.dkin.chevit.domain.base.IOUseCase | ||
import com.dkin.chevit.domain.base.None | ||
import com.dkin.chevit.domain.repository.NotificationRepository | ||
|
||
class SyncFirebaseMessageTokenUseCase( | ||
coroutineDispatcherProvider: CoroutineDispatcherProvider, | ||
private val notificationRepository: NotificationRepository, | ||
private val updatePushTokenUseCase: UpdatePushTokenUseCase | ||
) : IOUseCase<Unit, None>(coroutineDispatcherProvider) { | ||
override suspend fun execute(params: Unit): None { | ||
val pushToken = notificationRepository.getPushToken() | ||
val param = UpdatePushTokenUseCase.Param(pushToken) | ||
updatePushTokenUseCase(param) | ||
return None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
alias(libs.plugins.com.android.library) | ||
alias(libs.plugins.org.jetbrains.kotlin.android) | ||
} | ||
|
||
apply(from = project.rootProject.file("gradle-scripts/base.gradle")) | ||
apply(from = project.rootProject.file("gradle-scripts/hilt.gradle")) | ||
|
||
android { | ||
namespace = "com.dkin.chevit.presentation.notification" | ||
} | ||
|
||
dependencies { | ||
implementation(project(":core")) | ||
implementation(project(":domain")) | ||
|
||
implementation(libs.firebase.messaging.ktx) | ||
implementation(libs.androidx.lifecycle.process) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | ||
|
||
<application> | ||
<service | ||
android:name=".ChevitFirebaseMessagingService" | ||
android:exported="false" | ||
android:stopWithTask="false"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
</manifest> |
29 changes: 29 additions & 0 deletions
29
...src/main/java/com/dkin/chevit/presentation/notification/ChevitFirebaseMessagingService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.dkin.chevit.presentation.notification | ||
|
||
import androidx.lifecycle.ProcessLifecycleOwner | ||
import androidx.lifecycle.lifecycleScope | ||
import com.dkin.chevit.domain.usecase.notification.UpdatePushTokenUseCase | ||
import com.google.firebase.messaging.FirebaseMessagingService | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.launch | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class ChevitFirebaseMessagingService : FirebaseMessagingService() { | ||
@Inject | ||
lateinit var updatePushTokenUseCase: UpdatePushTokenUseCase | ||
|
||
private val processLifecycleScope by lazy { | ||
ProcessLifecycleOwner.get().lifecycleScope | ||
} | ||
|
||
override fun onNewToken(token: String) { | ||
super.onNewToken(token) | ||
Timber.d("onNewToken : $token") | ||
processLifecycleScope.launch { | ||
val param = UpdatePushTokenUseCase.Param(token) | ||
updatePushTokenUseCase(param) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters