package com.base.browserwhite.fcm

import android.content.Context
import android.util.Log
import com.base.browserwhite.MyApplication
import com.base.browserwhite.help.EventUtils
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale

object NotificationPushUtil {

    private val TAG = "NotificationPushUtil"

    const val PUSH_WHERE_TIMBER = "push_where_timber"//定时推送
    const val PUSH_WHERE_UN_INSTALL_BROADCAST = "push_where_un_install_broadcast"//安装卸载广播
    const val PUSH_WHERE_UNLOCK = "push_where_unlock"//解锁推送
    const val PUSH_WHERE_FCM = "push_where_fcm"//fcm推送


    /**
     * 统一调用入口
     * @param where [PUSH_WHERE_TIMBER]
     */
    fun Context.sendNotificationWhere(setActionId: Int?, where: String) {
        Log.d("glc", "sendNotificationWhere where=$where")
        val actionId: Int = setActionId ?: NotificationHelp.getNotificationId()
        if (MyApplication.PAUSED_VALUE == 1) {
            return
        }
        NotificationUiUtil.sendNotification(this, actionId)

        EventUtils.event("showNotification", where, null, false)
    }


    private fun getCurrentDate(): String {
        val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
        val currentDate = Calendar.getInstance().time
        return dateFormat.format(currentDate)
    }

}