I'm developing an application, related to Child Security, in Flutter.
A parent can request the child's application to send an Image or a 15 seconds Audio.
FCM is implemented and perfectly working fine when the application is running or in the background. When a notification received on Child's mobile application, the application moves to the relevant screen and performs the task.
But when the application is closed/terminated, it's not working. The notification is received, but the application doesn't start automatically. I have to click the notification, which I don't want to.
Can I achieve this, in Flutter? Something like WhatsApp or Facebook Messenger call feature?
What I have tried so far is, calling the main function on a notification received or runApp, but got no success.
void _firebaseMessagingBackgroundHandler(RemoteMessage message) {
main();
<------- and ------>
runApp(MaterialApp(home: ChildDashboard()));
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: CustomSplash(
imagePath: 'assets/images/logo.png',
backGroundColor: Colors.pink[50],
animationEffect: 'zoom-in',
logoSize: 1000,
home: sendToRelevantScreen(),
duration: 2500,
type: CustomSplashType.StaticDuration,
),
));
}