FCM notifications work for me when the app is in background or in foreground but not when the app is killed.
Here's my FCM configuration code:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print("Handling a background message: ${message.messageId}");
}
class CategoriesScreen extends StatefulWidget {
static const routeName = '/view-cateogries';
_CategoriesScreenState createState() => _CategoriesScreenState();
}
class _CategoriesScreenState extends State<CategoriesScreen> {
Future _screenFuture;
void initState() {
_saveDeviceToken(FirebaseMessaging.instance);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
super.initState();
}
I have read numeruos articles online and here on stackoverflow. For instance, one of the suggestions was to disable battery saver. I have tried that but no luck. Any ideas what I am missing?
I am using firebase-messaging version ^10.0.2