package com.base.scanqr.fcm

import android.annotation.SuppressLint
import com.base.scanqr.bean.NotificationSendBean
import com.base.scanqr.bean.NotificationSendBean.Companion.POPUP_WHERE_FCM
import com.base.scanqr.fcm.notification.MyNotificationManager
import com.base.scanqr.helper.EventUtils.event
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import org.json.JSONObject

@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class MessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        val data = JSONObject(remoteMessage.data.toString())
        event("FCM_Received", "MessagingService", data)
        val sendBean = NotificationSendBean(this, POPUP_WHERE_FCM, canSend = { true }, sendSuccess = {})
        MyNotificationManager.submitSendBean(sendBean)
    }
}