我正在使用 Flutter 很棒的通知。当应用程序关闭时单击通知时,我想将其定向到应用程序内的特殊页面。对我来说最简单的方法是什么?
我已经在 main.dart 中初始化了 Awesome_notifications 插件当我热重启时,在调试控制台中我收到此错误:
\n E/flutter ( 4447): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method initialize on channel awesome_notifications)\nE/flutter ( 4447): #0 MethodChannel._invokeMethod\npackage:flutter/\xe2\x80\xa6/services/platform_channel.dart:165\nE/flutter ( 4447): <asynchronous suspension>\nE/flutter ( 4447): #1 AwesomeNotifications.initialize (package:awesome_notifications/src/awesome_notifications_core.dart:174:18)\nE/flutter ( 4447): <asynchronous suspension>\nE/flutter ( 4447):\nE/flutter ( 4447): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method isNotificationAllowed on channel awesome_notifications)\nE/flutter ( 4447): #0 MethodChannel._invokeMethod\npackage:flutter/\xe2\x80\xa6/services/platform_channel.dart:165\nE/flutter ( 4447): <asynchronous suspension>\nRun Code Online (Sandbox Code Playgroud)\n这是我的代码:
\n主程序.dart
\nFuture<void> main() async {\n WidgetsFlutterBinding();\n await Hive.initFlutter();\n if (!Hive.isAdapterRegistered(AddEventModelAdapter().typeId)) {\n Hive.registerAdapter(AddEventModelAdapter());\n }\n AwesomeNotifications()\n …Run Code Online (Sandbox Code Playgroud) 我已经设置了与 Firebase Messaging 配合使用的所有内容。后台消息工作正常。但对于前台消息,我面临以下错误:用户必须有效并且有名称。
W/System.err(15714): java.lang.RuntimeException: User must be valid and have a name.
W/System.err(15714): at android.app.Notification$MessagingStyle.validate(Notification.java:7229)
W/System.err(15714): at android.app.Notification$Builder.build(Notification.java:6088)
W/System.err(15714): at androidx.core.app.NotificationCompatBuilder.buildInternal(NotificationCompatBuilder.java:410)
W/System.err(15714): at androidx.core.app.NotificationCompatBuilder.build(NotificationCompatBuilder.java:324)
W/System.err(15714): at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2430)
W/System.err(15714): at me.carda.awesome_notifications.notifications.NotificationBuilder.getNotificationBuilderFromModel(NotificationBuilder.java:425)
W/System.err(15714): at me.carda.awesome_notifications.notifications.NotificationBuilder.createNotification(NotificationBuilder.java:110)
W/System.err(15714): at me.carda.awesome_notifications.notifications.NotificationSender.showNotification(NotificationSender.java:209)
W/System.err(15714): at me.carda.awesome_notifications.notifications.NotificationSender.doInBackground(NotificationSender.java:128)
W/System.err(15714): at me.carda.awesome_notifications.notifications.NotificationSender.doInBackground(NotificationSender.java:34)
W/System.err(15714): at android.os.AsyncTask$3.call(AsyncTask.java:394)
W/System.err(15714): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(15714): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
W/System.err(15714): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(15714): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(15714): at java.lang.Thread.run(Thread.java:923)
Run Code Online (Sandbox Code Playgroud)
它是这样调用的:
AwesomeNotifications().createNotification(
content: NotificationContent(
id: uniqueIdInt(),
channelKey: 'basic_channel',
title: notification!.title,
body: notification.body,
notificationLayout: NotificationLayout.Messaging,
),
);
Run Code Online (Sandbox Code Playgroud)
有什么线索吗?
当运行我的 iOS 版 Flutter 应用程序时,出现以下错误:
\nXcode build done. 86.8s\nFailed to build iOS app\nCould not build the precompiled application for the device.\nSwift Compiler Error (Xcode): No such module \'shared_preferences_ios\'\n/Users/tomasward/Desktop/fredi_new/ios/Runner/AppDelegate.swift:3:7\nRun Code Online (Sandbox Code Playgroud)\n这是从这段代码派生出来的AppDelegate.swift:
import UIKit\nimport Flutter\nimport awesome_notifications\nimport shared_preferences_ios //error here\n\n@UIApplicationMain\n@objc class AppDelegate: FlutterAppDelegate {\n override func application(\n _ application: UIApplication,\n didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?\n ) -> Bool {\n GeneratedPluginRegistrant.register(with: self)\n \n if …Run Code Online (Sandbox Code Playgroud) 我想在我的颤动通知中添加一个按钮。按钮已显示,但我无法捕捉到该操作。
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 888,
channelKey: 'NetVideo',
title: 'NetVideo',
body: 'Server in ascolto'),
actionButtons: <NotificationActionButton>[
NotificationActionButton(key: 'yes', label: 'Yes'),
],
);
Run Code Online (Sandbox Code Playgroud)
AwesomeNotifications().actionStream 仍然存在吗?