我一直在尝试通过本地通知上的操作按钮来工作。但当单击它时,我无法在控制台上打印任何内容(应用程序在前台运行)。我正在使用flutter_local_notifications:^14.1.1
所有项目设置均已根据设置说明完成。我想指出大多数在线示例和教程都是从 main.dart 启动通知的。但就我而言,它的 Main.dart -> LoginPage -> HomePage(在 init 方法中调用的通知)
我尝试运行本地通知包的示例应用程序,该应用程序运行良好并触发操作按钮事件。我还将启动通知的部分函数复制到我的NotificationService 类中,但没有成功。我做了一些代码比较,并且在大多数情况下没有发现我的代码和示例应用程序之间有任何主要代码差异(但我可能会错过一些正在盯着我看的东西)
在 HomePage init 方法中,我调用NotificationService类,该类是根据文档设置的,如下所示:
NotificationService notifService = NotificationService();
notifService.showNotificationWithActions(
"Test Notification",
"Your have changes that needs approval.",
actions: <AndroidNotificationAction>[
const AndroidNotificationAction(dismissNotifID, 'DISMISS',
cancelNotification: true),
const AndroidNotificationAction(approveChangesID, 'APPROVE',
cancelNotification: false),
const AndroidNotificationAction(viewChangesID, 'VIEW',
cancelNotification: false),
],
);
Run Code Online (Sandbox Code Playgroud)
通知显示没有问题。但单击批准或查看不会打印我想要打印的内容。但是,控制台确实显示以下内容:
W/ActionBroadcastReceiver(26591):无法检索回调信息
每次按下按钮都会重复这一行
E/ActionBroadcastReceiver(26591):引擎已初始化
我似乎无法在按钮按下事件上打印任何其他内容。我在这里错过了什么或做错了什么。对此的任何帮助都是appriced。方向、代码帮助、建议..
通知服务类
class NotificationService {
FlutterLocalNotificationsPlugin _notificationsPlugin =
FlutterLocalNotificationsPlugin();
Future<bool?> initializeService() async {
_notificationsPlugin = FlutterLocalNotificationsPlugin();
// Initialization setting for android
const AndroidInitializationSettings …Run Code Online (Sandbox Code Playgroud) 桌子
| ID | 日期 | 模型 | 价格 |
|---|---|---|---|
| 6255 | 2018-01-31 | HZH98CC | 435.34 |
| 6256 | 2018-01-31 | CVVCDE7 | 23.24 |
| 6257 | 2018-01-31 | WWRT423 | 24.24 |
| 6258 | 2018-02-14 | DT4 | 43.23 |
| 6259 | 2018-02-14 | D42C | 243.2 |
如何使用查询/视图从数据库表中获取所有记录并将具有相同日期的行合并为一行?我不知道如何开始。我已经尝试过FOR XML,但没有得到我想要的结果
SELECT DISTINCT transactions.[id],
SUBSTRING(
(
SELECT ','+ transactions.model AS [text()]
FROM transactions
FOR XML PATH ('')
), 2, 1000) transactions
FROM transactions
Run Code Online (Sandbox Code Playgroud)
哪个返回
| ID | 模型 |
|---|---|
| 6255 | HZH98CC、CVVCDE7、WWRT423、DT4、D42C |
预期结果
| ID | 日期 | 模型 | 价格 |
|---|---|---|---|
| 6255,6256,6257 | 2018-01-31 | HZH98CC、CVVCDE7、WWRT423 | 435.34,23.24,24.24 |
| 6258,6259 | 2018-02-14 | DT4、D42C | 43.23,243.2 |
这是否可能或者我必须这样做
Select distinct [date]
From transactions Order by [date] …Run Code Online (Sandbox Code Playgroud)