You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the app is in "Background" or "Terminated" state, the notification is received silently. Meaning that the icon appears in the notification tray but the notification title and background is not shown.
Steps to reproduce
Steps to reproduce the behavior:
Create a new flutter app
Create a new firebase project
Follow the instruction to add firebase_core and firebase_messaging from FlutterFire. Ignore the IOS part but do all the Android part.
Launch the app on your Android phone or in an Android emulator
Click on the home button to enter the "Background" state.
See on your phone that the notification appears in the notification tray but not peaked into view.
Click to see the flutter app (main.dart)
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
FirebaseMessaging messaging = FirebaseMessaging.instance;
print(await messaging.getToken());
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print('Message also contained a notification: ${message.notification}');
}
});
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
}
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
await Firebase.initializeApp();
print("Handling a background message: ${message.messageId}");
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Title'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Additional context
Tested on:
Real phone (Huawei LDN-L21) on Android 8.0
Emulator (Pixel 2) on Android Android 7.1
Emulator (Pixel 3a) on Android 10
Emulator (Pixel 4) on Android 11
Flutter doctor
Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.3, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.51.0)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
Hi @lulupointu
I see there's an open issue addressing the case you described #2603.
Please follow up on that issue, I'm closing the current one as a duplicate.
If you disagree, please write in the comments and I will reopen it.
Thank you
#2603 is still open and there is no mention of a fix yet so I would expect it to also appear on 8.0.0-dev.8. This also seems to primarily be an Android issue, I'm seeing the exact same as you on Android with dev.8.
You can comment on #2603 to track the fact that this reproduces in 8.0.0-dev.8.
Bug report
Describe the bug
When the app is in "Background" or "Terminated" state, the notification is received silently. Meaning that the icon appears in the notification tray but the notification title and background is not shown.
Steps to reproduce
Steps to reproduce the behavior:
Click to see the flutter app (main.dart)
Additional context
Tested on:
Flutter doctor
Click To Expand
Flutter dependencies
Click To Expand
The text was updated successfully, but these errors were encountered: