简体   繁体   English

扑:Firebase消息传递导航器不起作用

[英]flutter: firebase messaging navigator not working

I have an issue implementing firebase messaging. 我在实现Firebase消息传递时遇到问题。

When application in foreground notification data printed in debug log, but navigator not working. 当前台通知中的应用程序数据打印在调试日志中,但导航器不起作用时。 When application in background and notification had tapped, notification data printed in debug log but navigator is not working. 轻按后台的应用程序和通知后,通知数据将打印在调试日志中,但导航器不起作用。

Here's my code 这是我的代码

@override
  void initState() {
    // TODO: implement initState
    super.initState();
    initiateData();
  }

  initiateData() async{
    firebase = new FirebaseMessaging();
    firebase.configure(
      onLaunch: (message){
        Log.write("on launch fcm");

      },

      onMessage: (message){
        Log.write("on message fcm");
        Log.write(json.encode(message));


        TanamDuitNavigator.present(context,
          child: new FullWebPages(
            language: "id",
            url: "https://example.com",
          )
        );
      },
      onResume: (message){
        Log.write("on resume fcm");
      }
    );
    firebase.requestNotificationPermissions();
    firebase.onIosSettingsRegistered.listen(
      (IosNotificationSettings setting){
        Log.write("Setting registered : $setting");
      });
    firebase.getToken().then((token){
      Log.write("fcm token : "+token);
      TanamStore.saveFcmToken(token);
    }).timeout(const Duration(seconds: 5));
  }

here it's what actually TanamduitNavigator presenting 这就是TanamduitNavigator实际呈现的内容

static Future<dynamic> present(BuildContext context,
    {bool opq = false,
     Widget child,
     Widget curPage,
     Color barrier = ColorCollections.blackBarrier
    }
  ){
    return Navigator.of(context).push(new PageRouteBuilder(
      opaque: opq,
      pageBuilder: (_,Animation<double> animation,__){
        return child;
      },
      barrierColor: barrier,
      barrierDismissible: false,
      transitionsBuilder: (_,Animation<double>animation,__,Widget child){
        return new FadeTransition(
          opacity: animation,
          child: new SlideTransition(
            position: new Tween<Offset>(begin: new Offset(0.0, 0.5), end: new Offset(0.0, 0.0)).animate(animation),
            child: child,
          ),
        );
      },
      transitionDuration: const Duration(milliseconds: 200),
    ));
  }

In build method I called new object MaterialApp. 在构建方法中,我调用了新对象MaterialApp。 Any idea why navigator not working? 知道为什么导航器不起作用吗?

thanks 谢谢

i already solved. 我已经解决了。 its more likely about stack route. 关于堆栈路由的可能性更大。

because i build non linear navigator apps, so i reconfigure every each parent page. 因为我构建了非线性导航器应用程序,所以我重新配置了每个父页面。 and it's work. 这是工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM