0

Hi I'm building a VoIP App in Flutter. I use background_fetch to run a headless task in order to work even if the app is closed. The listener is working, and a notification is sent. But, as the application is closed, the push notification with wake up the app (so home.dart for example) and I would like the push my call screen widget. I see two solution but I don't know how to do it :

  • the headless task from background_fetch is independent, so I can't transfer my service call data to my app (main) when the user open it, so the call is lost ...
  • I try to push the right widget (Router.go(/callscreen)) but it's not working.

What can I do in order to fix this ? Thank !

RobMat
  • 1
  • 1

1 Answers1

0

You are using 2 services in background, flutter-local-notification and background-fetch. It's too much. You can use flutter-local-notification in backgound only. Have a look here.

    final newRouteName = "callScreen";//Future onSelectNotification(String payload) async 
    bool isNewRouteSameAsCurrent = false;

    Navigator.popUntil(context, (route) {
      if (route.settings.name == newRouteName) {
        isNewRouteSameAsCurrent = true;
      }
      return true;
    });

    if (!isNewRouteSameAsCurrent) {
      Navigator.of(context).push(CallScreen())
      
    }
mario francois
  • 1,291
  • 1
  • 9
  • 16
  • Thanks for your reply. I see but I'm not using FCM token, I need to register on my VoIP Server in background. The problem is only when the app is closed by user. Then I add only a headless task (background-fetch) which will run even if the app is closed or terminate. When I received call, I tried to push a specific widget but the notification from local_notification launch the app and I lost my data from headless task... – RobMat Jul 05 '21 at 14:26