'How i can make Flutter application start when it receives background firebase message even if the screen is locked i want my app to start

I tried this code but it didn't works:

package com.example.flutter_telegram

import android.os.Bundle
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import android.content.Intent
import android.util.Log
import androidx.annotation.NonNull
import com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin
import io.flutter.app.FlutterApplication;
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        GeneratedPluginRegistrant.registerWith(this)
      
        val engine = FlutterEngine(applicationContext)

        MethodChannel(engine.dartExecutor,"flutter/MethodChannelDemo").setMethodCallHandler{
            call, _ ->
            if (call.method=="Documents"){
                Log.d("TAG", "message")
                val intent = Intent(this, MainActivity::class.java)
                startActivity(intent)
            }
        }
    }
}

and I have tried android_intent package but I got an exception:

PlatformException(error, No Activity found to handle Intent { act=android.intent.action.VIEW dat=.MainActivity (has extras) }, null)



Solution 1:[1]

I don't think that IOS supports this type of behavior

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MajdNaji