Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id("com.google.devtools.ksp")
id("androidx.room")
alias(libs.plugins.compose.compiler)
id("com.google.gms.google-services")
}

repositories {
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/kotlin/com/gemwallet/android/di/BuildInfoModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gemwallet.android.di

import android.content.Context
import com.gemwallet.android.cases.device.RequestPushToken
import com.gemwallet.android.cases.pushes.ShowSystemNotification
import com.gemwallet.android.flavors.StoreRequestPushToken
import com.gemwallet.android.flavors.isNotificationsAvailable
Expand All @@ -20,14 +21,23 @@ object BuildInfoModule {

@Provides
@Singleton
fun provideBuildInfo(platformStore: PlatformStore): BuildInfo {
fun provideBuildInfo(
platformStore: PlatformStore,
requestPushToken: RequestPushToken,
): BuildInfo {
return BuildInfo(
platformStore = platformStore,
versionName = com.gemwallet.android.BuildConfig.VERSION_NAME,
requestPushToken = StoreRequestPushToken(),
requestPushToken = requestPushToken,
)
}

@Provides
@Singleton
fun provideRequestPushToken(): RequestPushToken {
return StoreRequestPushToken()
}
Comment thread
furenster marked this conversation as resolved.

@Provides
@Singleton
fun provideShowSystemNotification(@ApplicationContext context: Context): ShowSystemNotification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class DeviceRepository(

override suspend fun syncDeviceInfo() {
val pushToken = getPushToken()
val pushEnabled = pushToken.isNotEmpty()
val pushEnabled = getPushEnabled()
Comment thread
furenster marked this conversation as resolved.
val deviceId = getDeviceIdCase.getDeviceId()
val device = Device(
id = deviceId,
platform = Platform.Android,
platformStore = platformStore,
token = "",
token = pushToken,
locale = getLocale(Locale.getDefault()),
isPushEnabled = pushEnabled,
isPriceAlertsEnabled = enablePriceAlert.isPriceAlertEnabled(),
Expand All @@ -74,7 +74,7 @@ class DeviceRepository(
}
}
if (pushEnabled && pushToken.isEmpty()) {
requestPushToken.invoke { pushToken ->
requestPushToken.requestToken { pushToken ->
setPushToken(pushToken)
register()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package com.gemwallet.android.flavors

import android.content.Context
Comment thread
furenster marked this conversation as resolved.
import android.util.Log
Comment thread
furenster marked this conversation as resolved.
Outdated
import com.gemwallet.android.cases.device.RequestPushToken
import com.google.firebase.FirebaseApp
import com.google.firebase.messaging.FirebaseMessaging

class StoreRequestPushToken : RequestPushToken {
override suspend fun invoke(callback: (String) -> Unit) {

override fun init(context: Context) {
FirebaseApp.initializeApp(context)
}

override suspend fun requestToken(callback: (String) -> Unit) {
Comment thread
furenster marked this conversation as resolved.
try {
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
val token = if (task.isSuccessful) { task.result } else { "" }
Expand All @@ -14,6 +22,7 @@ class StoreRequestPushToken : RequestPushToken {
callback("")
}
}

}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.gemwallet.android.flavors

import android.content.Context
Comment thread
furenster marked this conversation as resolved.
import com.gemwallet.android.cases.device.RequestPushToken

class StoreRequestPushToken : RequestPushToken {
override suspend fun invoke(callback: (String) -> Unit) {

override fun init(context: Context) {}

override suspend fun requestToken(callback: (String) -> Unit) {
Comment thread
furenster marked this conversation as resolved.
callback("")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.gemwallet.android.cases.device

fun interface RequestPushToken {
suspend fun invoke(callback: (String) -> Unit)
import android.content.Context

interface RequestPushToken {

fun init(context: Context)

suspend fun requestToken(callback: (String) -> Unit)
Comment thread
furenster marked this conversation as resolved.
}
Loading