got full screen notifications working, with routing to a notification page.
This commit is contained in:
parent
b4567cc7b2
commit
f9b0f6d226
1 changed files with 19 additions and 9 deletions
|
@ -56,6 +56,7 @@ void main() async {
|
||||||
initializationSettings,
|
initializationSettings,
|
||||||
onSelectNotification: (String? payload) async {
|
onSelectNotification: (String? payload) async {
|
||||||
selectedNotificationPayload = payload;
|
selectedNotificationPayload = payload;
|
||||||
|
print("onSelectNotification");
|
||||||
selectNotificationSubject.add(payload);
|
selectNotificationSubject.add(payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,26 +69,29 @@ void main() async {
|
||||||
String initialRoute = "/";
|
String initialRoute = "/";
|
||||||
if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) {
|
if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) {
|
||||||
selectedNotificationPayload = notificationAppLaunchDetails!.payload;
|
selectedNotificationPayload = notificationAppLaunchDetails!.payload;
|
||||||
|
print("Started by notification");
|
||||||
initialRoute = "/event/notification";
|
initialRoute = "/event/notification";
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp(
|
runApp(PizzaPlanner(initialRoute));
|
||||||
MaterialApp(
|
|
||||||
title: "PizzaPlanner",
|
|
||||||
initialRoute: initialRoute,
|
|
||||||
onGenerateRoute: RouteGenerator.generateRoute,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
//await Hive.close();
|
//await Hive.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PizzaPlanner extends StatefulWidget {
|
class PizzaPlanner extends StatefulWidget {
|
||||||
|
final String initialRoute;
|
||||||
|
|
||||||
|
PizzaPlanner(this.initialRoute);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PizzaPlannerState createState() => PizzaPlannerState();
|
PizzaPlannerState createState() => PizzaPlannerState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PizzaPlannerState extends State<PizzaPlanner> {
|
class PizzaPlannerState extends State<PizzaPlanner> {
|
||||||
|
// need this because in _configureSelectNotificationSubject() we need to pushNamed a route
|
||||||
|
// but only descendants of a MaterialApp have access to the Navigator,
|
||||||
|
// and this build() returns the MaterialApp
|
||||||
|
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState(){
|
void initState(){
|
||||||
|
@ -97,12 +101,18 @@ class PizzaPlannerState extends State<PizzaPlanner> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return PizzaEventsPage();
|
return MaterialApp(
|
||||||
|
title: "PizzaPlanner",
|
||||||
|
initialRoute: this.widget.initialRoute,
|
||||||
|
navigatorKey: this.navigatorKey,
|
||||||
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _configureSelectNotificationSubject() {
|
void _configureSelectNotificationSubject() {
|
||||||
selectNotificationSubject.stream.listen((String? payload) async {
|
selectNotificationSubject.stream.listen((String? payload) async {
|
||||||
await Navigator.pushNamed(context, '/event/notification', arguments: payload);
|
print("tapped on notification");
|
||||||
|
await this.navigatorKey.currentState?.pushNamed('/event/notification', arguments: payload);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue