package com.example.cuida.services;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.example.cuida.utils.NotificationHelper;

public class AlarmReceiver extends BroadcastReceiver {
    private static final String TAG = "AlarmReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null) {
            String title = intent.getStringExtra("EXTRA_TITLE");
            String message = intent.getStringExtra("EXTRA_MESSAGE");
            int notificationId = intent.getIntExtra("EXTRA_NOTIFICATION_ID", (int) System.currentTimeMillis());

            Log.d(TAG, "Alarm received! Title: " + title + " Msg: " + message);

            NotificationHelper notificationHelper = new NotificationHelper(context);
            if (title != null && title.contains("Medicamento")) {
                notificationHelper.sendNotification(title, message, notificationId, "MEDICATION_CHANNEL_ID");
            } else {
                notificationHelper.sendNotification(title, message, notificationId, "APPOINTMENT_CHANNEL_ID");
            }
        }
    }
}
