package com.base.datarecovery.fcm.work

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.base.datarecovery.fcm.NotificationUtil
import com.base.datarecovery.help.BaseApplication
import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.EventUtils


class AlterReceiver : BroadcastReceiver() {
    override fun onReceive(p0: Context?, p1: Intent?) {
        EventUtils.event("alarm_push")
        val firstAlemtime = AppPreferences.getInstance().getLong("firstAlemtime", 0L)
        if (firstAlemtime > 0) {
            val leatTime = System.currentTimeMillis()
            if (leatTime - firstAlemtime >= 1000 * 30 * 60) {
                NotificationUtil.sendNotification(BaseApplication.context, "alarm")
            }
        }
        AppPreferences.getInstance().put("firstAlemtime", System.currentTimeMillis())
        return
    }
}