File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -114,19 +114,21 @@ class _Application extends State<Application> {
114
114
115
115
// If the message also contains a data property with a "type" of "chat",
116
116
// navigate to a chat screen
117
- if (initialMessage != null && initialMessage.data['type'] == 'chat') {
118
- Navigator.pushNamed(context, '/chat',
119
- arguments: ChatArguments(initialMessage));
117
+ if (initialMessage != null) {
118
+ _handleMessage(initialMessage);
120
119
}
121
120
122
121
// Also handle any interaction when the app is in the background via a
123
122
// Stream listener
124
- FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
125
- if (message.data['type'] == 'chat') {
126
- Navigator.pushNamed(context, '/chat',
127
- arguments: ChatArguments(message));
128
- }
129
- });
123
+ FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
124
+ }
125
+
126
+ void _handleMessage(RemoteMessage message) {
127
+ if (message.data['type'] == 'chat') {
128
+ Navigator.pushNamed(context, '/chat',
129
+ arguments: ChatArguments(message),
130
+ );
131
+ }
130
132
}
131
133
132
134
@override
You can’t perform that action at this time.
0 commit comments