Added home-screen app-icon Notification badge
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/chatList/chatListProps.dart';
|
||||
import '../model/message/messageProps.dart';
|
||||
import '../widget/debug/debugTile.dart';
|
||||
import '../widget/debug/jsonViewer.dart';
|
||||
import 'notificationTasks.dart';
|
||||
|
||||
class NotificationController {
|
||||
@pragma('vm:entry-point')
|
||||
static Future<void> onBackgroundMessageHandler(RemoteMessage message) async {
|
||||
NotificationTasks.updateBadgeCount(message);
|
||||
return; // Displaying the notification is curently done via the Firebase SDK itself. The Message is server-generated.
|
||||
// log("Handling a background notification: ${message.messageId}");
|
||||
|
||||
//
|
||||
// await Firebase.initializeApp();
|
||||
// AccountData().waitForPopulation().then((value) {
|
||||
@ -38,8 +39,24 @@ class NotificationController {
|
||||
}
|
||||
|
||||
static Future<void> onForegroundMessageHandler(RemoteMessage message, BuildContext context) async {
|
||||
//NotificationService().showToast(message: "Du hast eine neue Talk Nachricht!", context: context);
|
||||
Provider.of<ChatListProps>(context, listen: false).run(renew: true);
|
||||
Provider.of<MessageProps>(context, listen: false).run(renew: true);
|
||||
NotificationTasks.updateProviders(context);
|
||||
NotificationTasks.updateBadgeCount(message);
|
||||
}
|
||||
|
||||
static Future<void> onAppOpenedByNotification(RemoteMessage message, BuildContext context) async {
|
||||
NotificationTasks.updateProviders(context);
|
||||
|
||||
DebugTile(context).run(() {
|
||||
showDialog(context: context, builder: (context) => AlertDialog(
|
||||
title: const Text("Notification report"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text("Dieser Bericht wird angezeigt, da du den Entwicklermodus aktiviert hast und die App über eine Benachrichtigung geöffnet wurde."),
|
||||
Text(JsonViewer.format(message.data)),
|
||||
],
|
||||
),
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user