feat: 포그라운드 상태에서 FCM data-only 수신 시 인앱 팝업 표시

This commit is contained in:
2025-04-22 18:06:47 +09:00
parent c0ad98f285
commit b077a361b9
2 changed files with 40 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import android.content.Intent
import android.media.RingtoneManager
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import kr.co.vividnext.sodalive.R
@@ -20,7 +21,11 @@ class SodaFirebaseMessagingService : FirebaseMessagingService() {
if (SharedPreferenceManager.token.isNotBlank()) {
when {
remoteMessage.data.isNotEmpty() -> {
if (remoteMessage.data["message"]?.isNotBlank() == true) {
if (remoteMessage.data["type"] == "POINT_GRANTED") {
val intent = Intent("ACTION_POINT_GRANTED")
intent.putExtra("message", remoteMessage.data["message"])
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
} else if (remoteMessage.data["message"]?.isNotBlank() == true) {
sendNotification(remoteMessage.data)
}
}