package com.base.scanqr.fcm.alarm

import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.base.scanqr.bean.NotificationSendBean
import com.base.scanqr.bean.NotificationSendBean.Companion.POPUP_WHERE_ALARM
import com.base.scanqr.fcm.notification.MyNotificationManager
import com.base.scanqr.fcm.work.RepeatingWorker.Companion.schedulePeriodicWork
import com.base.scanqr.helper.EventUtils
import com.base.scanqr.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
    }

}