package com.easy.clean.business.push.fcm

import android.annotation.SuppressLint
import android.util.Log
import com.easy.clean.bean.push.NotificationSendBean
import com.easy.clean.bean.push.NotificationSendBean.Companion.POPUP_WHERE_FCM
import com.easy.clean.business.helper.EventUtils.event
import com.easy.clean.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))
    }
}