Для обработки щелчка уведомления и маршрута навигации в выключенном состоянии я использую следующий код:
Код: Выделить всё
Future setupFirebaseMessaging() async {
// this code is working fine for iOS app in killed state but for android app remoteMessage is always return null
final remoteMessage = await FirebaseMessaging.instance.getInitialMessage();
if (remoteMessage == null) { // always null in android killed state
if (isUserOnboarded) {
openDashboardPage();
} else {
openOnBoardingPage();
}
} else {
if (navigatorKey.currentContext != null) {
Navigator.push(
navigatorKey.currentContext!,
MaterialPageRoute(
builder: (context) => DashboardPage(
catId: remoteMessage.data['category_id'],
showMain: remoteMessage.data['showMain'],
offer: remoteMessage.data['offer'],
)),
);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... in-android
Мобильная версия