package com.swiftcleaner.chovey.business.push

import android.app.NotificationManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.swiftcleaner.chovey.GlobalConfig.KEY_NOTIFICATION_ID

class NotificationCancelReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        val id = intent?.getIntExtra(KEY_NOTIFICATION_ID, -1)
        if (id != -1) {
            NotificationUtils.stopNotificationHandler()
            val notificationManager = context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
            if (id != null) {
                notificationManager.cancel(id)
            }
        }
    }
}