package com.swiftcleaner.chovey.business.push

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.swiftcleaner.chovey.CleanApplication
import com.swiftcleaner.chovey.business.EventUtils
import org.json.JSONObject

class FirebaseReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context?, intent: Intent?) {
        val requestId = intent?.extras?.getString("requestID")
        Log.d("FCM", "FcmReceiver onReceive requestId: $requestId")
        if (!requestId.isNullOrEmpty()) {
            val json = JSONObject()
            json.put("requestID", requestId)
            EventUtils.event("FCM_Received", ext = json)
        }
        NotificationUtils.sendNotification(CleanApplication.context, "fcm_receiver")
    }
}