简体   繁体   English

Flutter FCM 推送通知在用户点击通知时显示空白屏幕 state

[英]Flutter FCM push notification show the blank screen when user tap on Notification in killed state

When user tap on push notification in termination state of app then it will open blank screen and app stuck on this screen and when app is in background then it will navigate the user in desire screen so I face issue in killed state that app will stuck on blank screen when user tap on push notification.当用户在应用程序终止 state 时点击推送通知时,它将打开空白屏幕并且应用程序卡在该屏幕上,当应用程序处于后台时,它将在期望屏幕中导航用户,所以我面临被杀死的问题 state 该应用程序将卡在用户点击推送通知时出现黑屏。

For app active state and background state, widget tree will be exist and navigating to correct screen.对于应用程序活动 state 和背景 state,小部件树将存在并导航到正确的屏幕。 When in killed state, that route will not exists and trying to navigate to that screen..So it got null exception, results in blank screen.当杀死 state 时,该路由将不存在并尝试导航到该屏幕。因此它出现 null 异常,导致黑屏。 I got same issue and found this as main cause.我遇到了同样的问题,发现这是主要原因。

I used try and catch block to catch exception and avoid null pointer exception.我使用 try 和 catch 块来捕获异常并避免 null 指针异常。 So initial route screen is loading without white screen now.所以初始路线屏幕现在正在加载而没有白屏。

try
 {
   // actual code here.
 }
 catch(exp)
 {
   // catch exception here
   print("exception in app kill state is $exp");
 } 

  

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

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