package com.base.scanqrclear.fcm.alarm

import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.base.scanqrclear.bean.NotificationSendBean
import com.base.scanqrclear.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
import com.base.scanqrclear.fcm.notification.MyNotificationManager
import com.base.scanqrclear.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import com.base.scanqrclear.helper.EventUtils
import com.base.scanqrclear.utils.LogEx

/**
 *
 */
class AlarmReceiver : BroadcastReceiver() {

    private val TAG = "AlarmJobReceiver"

    @SuppressLint("UnsafeProtectedBroadcastReceiver")
    override fun onReceive(context: Context, intent: Intent?) {
        LogEx.logDebug(TAG, "AlarmJobReceiver onReceive")
        EventUtils.event("alarm_push")
        val sendBean = NotificationSendBean(context, POPUP_WHERE_ALARM, canSend = { true }, sendSuccess = {})
        MyNotificationManager.submitSendBean(sendBean)
        schedulePeriodicWork(context)
        return
    }

}