package com.example.proxibuy

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.plugin.common.MethodChannel

class ActionReceiver : BroadcastReceiver() {
    private val CHANNEL = "custom_notification"

    override fun onReceive(context: Context, intent: Intent) {
        val action = intent.getStringExtra("action")
        val flutterEngine: FlutterEngine? = FlutterEngineCache.getInstance().get("my_engine_id")
        val methodChannel = flutterEngine?.let { MethodChannel(it.dartExecutor.binaryMessenger, CHANNEL) }
        if(action != null){
            methodChannel?.invokeMethod(action, null)
        }
        }
}
