package com.craigvg.lichun_android.services import android.util.Log import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage import com.craigvg.lichun_android.managers.PushNotificationManager import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @AndroidEntryPoint class BaoLifeMessagingService : FirebaseMessagingService() { @Inject lateinit var pushNotificationManager: PushNotificationManager companion object { private const val TAG = "BaoLifeMessaging" } override fun onNewToken(token: String) { super.onNewToken(token) Log.d(TAG, "New FCM token: $token") pushNotificationManager.updateToken(token) } override fun onMessageReceived(message: RemoteMessage) { super.onMessageReceived(message) Log.d(TAG, "Message received from: ${message.from}") // Handle data payload if (message.data.isNotEmpty()) { pushNotificationManager.handlePushData(message.data) } // Handle notification payload (when app is in foreground) message.notification?.let { notification -> pushNotificationManager.showEventNotification( title = notification.title ?: "BaoLife", message = notification.body ?: "" ) } } }