|
|
@@ -1,4 +1,7 @@
|
|
|
import 'package:custom_notification/custom_notification.dart';
|
|
|
+import 'package:electronic_assistant/data/bean/talks.dart';
|
|
|
+import 'package:electronic_assistant/module/talk/view.dart';
|
|
|
+import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
|
|
class NotificationUtil {
|
|
|
NotificationUtil._();
|
|
|
@@ -18,4 +21,60 @@ class NotificationUtil {
|
|
|
notificationId, isRecording, formatDuration(recordDuration),
|
|
|
channelId: channelId, channelName: channelName);
|
|
|
}
|
|
|
+
|
|
|
+ static int _analyseNotificationId = 2000;
|
|
|
+
|
|
|
+ static int getAnalyseNotificationId() {
|
|
|
+ return _analyseNotificationId++;
|
|
|
+ }
|
|
|
+
|
|
|
+ static void showAnalyseSuccessNotification(String talkId) async {
|
|
|
+ final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
|
|
+ FlutterLocalNotificationsPlugin();
|
|
|
+
|
|
|
+ const AndroidInitializationSettings initializationSettingsAndroid =
|
|
|
+ AndroidInitializationSettings('@mipmap/ic_launcher');
|
|
|
+
|
|
|
+ const InitializationSettings initializationSettings =
|
|
|
+ InitializationSettings(
|
|
|
+ android: initializationSettingsAndroid,
|
|
|
+ );
|
|
|
+
|
|
|
+ await flutterLocalNotificationsPlugin.initialize(
|
|
|
+ initializationSettings,
|
|
|
+ onDidReceiveNotificationResponse:
|
|
|
+ (NotificationResponse notificationResponse) async {
|
|
|
+ if (notificationResponse.payload != null) {
|
|
|
+ TalkPage.startById(notificationResponse.payload!);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+ const AndroidNotificationDetails androidPlatformChannelSpecifics =
|
|
|
+ AndroidNotificationDetails(
|
|
|
+ 'talk_analyse_success',
|
|
|
+ '谈话分析通知',
|
|
|
+ channelDescription: '谈话分析成功',
|
|
|
+ importance: Importance.max,
|
|
|
+ priority: Priority.high,
|
|
|
+ );
|
|
|
+
|
|
|
+ const NotificationDetails platformChannelSpecifics =
|
|
|
+ NotificationDetails(android: androidPlatformChannelSpecifics);
|
|
|
+
|
|
|
+ await flutterLocalNotificationsPlugin.show(
|
|
|
+ getAnalyseNotificationId(),
|
|
|
+ '小听谈话分析完成',
|
|
|
+ '老板,谈话分析已完成,快点击查看吧。',
|
|
|
+ platformChannelSpecifics,
|
|
|
+ payload: talkId,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+// static void showAnalyseResultNotification(
|
|
|
+// int notificationId, bool isSuccess, String talkId,
|
|
|
+// {required String channelId, required String channelName}) {
|
|
|
+// CustomNotification.showAnalyseResultNotification(
|
|
|
+// notificationId, isSuccess, talkId,
|
|
|
+// channelId: channelId, channelName: channelName);
|
|
|
+// }
|
|
|
}
|