package com.simplecleaner.app.business.push.fcm

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