package importantedto.growedto.umbrellaedto;

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import org.json.JSONException;
import org.json.JSONObject;

import importantedto.Exhibitionedto;
import importantedto.gallonedto.Rideredto;


@SuppressLint("MissingFirebaseInstanceTokenRefresh")
public class Cooperateedto extends FirebaseMessagingService {

    private static final String TAG = "MessagingService";

    @Override
    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        String id = remoteMessage.getMessageId();
        JSONObject ext = new JSONObject();
        try {
            ext.put("getMessageType", remoteMessage.getMessageType());
            ext.put("getData", remoteMessage.getData());
            ext.put("getCollapseKey", remoteMessage.getCollapseKey());
            ext.put("getFrom", remoteMessage.getFrom());
            ext.put("getPriority", remoteMessage.getPriority());
            ext.put("getSenderId", remoteMessage.getSenderId());
            ext.put("getSentTime", remoteMessage.getSentTime());
        } catch (JSONException e) {
            Rideredto.INSTANCE.event("FCM_Received_Error", id, ext, false);
            throw new RuntimeException(e);
        } finally {
        }
        Rideredto.INSTANCE.event("FCM_Received", id, ext, false);

        sendLocalNotification();
    }

    // Consider implementing this method if local notifications are needed
    private void sendLocalNotification() {
        Appleedto.INSTANCE.sendNotification(Exhibitionedto.context, "MessagingService");
    }

}