package com.dumpster.cleaner.business.push.fcm

import android.annotation.SuppressLint
import android.util.Log
import com.dumpster.cleaner.bean.push.NotificationSendBean
import com.dumpster.cleaner.bean.push.NotificationSendBean.Companion.POPUP_WHERE_FCM
import com.dumpster.cleaner.business.helper.EventUtils.event
import com.dumpster.cleaner.business.push.notification.MyNotificationManager
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import org.json.JSONObject

@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class MessagingService : FirebaseMessagingService() {

    private val TAG = "MessagingService"
    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        Log.e(TAG, "FCM_Received MessagingService")
        val data = JSONObject(remoteMessage.data.toString())
        event("FCM_Received", "MessagingService", data)
        MyNotificationManager.submitSendBean(NotificationSendBean(this, POPUP_WHERE_FCM))
    }
}