package com.base.appzxhy.fcm.alarm

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