26 lines
871 B
Dart
26 lines
871 B
Dart
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
import 'package:hub/main.dart';
|
|
|
|
void showFlutterNotification(RemoteMessage message) {
|
|
RemoteNotification? notification = message.notification;
|
|
AndroidNotification? android = message.notification?.android;
|
|
if (notification != null && android != null && !kIsWeb) {
|
|
flutterLocalNotificationsPlugin.show(
|
|
notification.hashCode,
|
|
notification.title,
|
|
notification.body,
|
|
NotificationDetails(
|
|
android: AndroidNotificationDetails(
|
|
channel.id,
|
|
channel.name,
|
|
channelDescription: channel.description,
|
|
// one that already exists in example app.
|
|
icon: 'launch_background',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|