- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经尝试使用 Flutter 实现 Firebase Cloud Messaging,并且在我使用“本地通知”插件显示通知之前我是成功的
我的通知在前台工作正常,但在后台显示此错误:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method show on channel dexterous.com/flutter/local_notifications)
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
class NotificationHandler{
static final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); // make it a static field of the class
static void initNotification()
{
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
var initializationSettingsAndroid = AndroidInitializationSettings('@mipmap/ic_launcher');
var initializationSettingsIOS = IOSInitializationSettings(
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: onSelectNotification);
}
static Future onSelectNotification(String payload) async {
if (payload != null) {
print('notification payload: ' + payload);
}
}
static Future onDidReceiveLocalNotification(int id, String title, String body, String payload) {
print(title+" "+body);
}
}
static void showNotification(data, data2) async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'dexterous.com.flutter.local_notifications', 'your channel name', 'your channel description',
importance: Importance.Max,
priority: Priority.High);
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await NotificationHandler.flutterLocalNotificationsPlugin
.show(
0,
data,
data2,
platformChannelSpecifics,
payload: 'Custom_Sound',
);
}
最佳答案
我找到了解决方案,这就是为什么在平台端我们不注册外部插件
添加你的 FCMPluginRegistrant.java 像
public final class FirebaseCloudMessagingPluginRegistrant {
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
FlutterLocalNotificationsPlugin.registerWith(registry.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = FirebaseCloudMessagingPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}
@Override
public void registerWith(PluginRegistry registry) {
FirebaseCloudMessagingPluginRegistrant.registerWith(registry);
}
关于firebase - MissingPluginException(在 channel dexterous.com/flutter/local_notifications 上找不到方法显示的实现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60471697/
我最近在我的 flutter 应用程序中安装了谷歌地图,但我一直收到这个错误, MissingPluginException (MissingPluginException(No implementa
我正在使用shared_preferences:^ 0.5.6。当我在workmanager中调用共享首选项时,出现以下错误。 Unhandled Exception: MissingPluginEx
代码 var flutterWebviewPlugin = new FlutterWebviewPlugin(); String url = "https://www.google.com"; @ov
我最近一直在使用一些 flutter 插件。许多都完美运行,但我几次偶然发现令人沮丧的错误,通常导致放弃插件。 这是我得到的最后一个,schedule_notifications : E/flutte
我有一段简单的代码,main.dart。任何形式的帮助将不胜感激。我正在使用 geolocator: ^5.1.3 我只是想获取用户的位置。但它显示: MissingPluginException(N
运行依赖于 SharedPreferences 插件的测试总是会导致 MissingPluginException(No implementation found for method getAll
我正在构建一个 Flutter 应用程序,当设备连接到另一个蓝牙设备时,它能够执行一些操作。这个应用程序应该可以在 Android 和 iOS 上运行,但为了简单起见,我将在这篇文章中关注 Andro
我有几个插件有问题 image_picker: ^0.6.2+3 , location: ^2.3.5 ,... 我愿意 flutter 干净什么都没有改变 安卓设备: SM-N900 安卓版本: 5
我试图让 google 登录插件正常工作,但没有成功。我已经把它放在我的 pubspec.yaml 中并运行 flutter packages get 但仍然没有运气。抛出以下异常: E/flutte
我正在尝试使用插件 _launchURL(url) async { await launch("www.google.com"); } 我放“www.google.com”只是为了调试。 我得到的
下面我分享了我的 flutter 代码,它只需选择一个图像并在获得所需权限后将其显示在屏幕上。然而,该代码在 Android 上运行良好,但在我尝试在网络上上传图像时出现 MissingPluginE
我正在使用 video_thumbnail 0.2.4 包以获取缩略图形式的视频 url。如果我从 android 设备上传视频,那么它的工作完美但如果我使用 iPhone 设备,总是得到错误 Mis
使用唤醒锁时,我在调试控制台中收到此错误: E/flutter (17630): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exce
当我尝试用我的 flutter 项目初始化 firebase 时,出现此错误: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Excep
我有一个 flutter 应用程序,我正在编写一个测试用例,将应用程序的当前版本与可用的最新版本进行比较。该函数仅获取 currentVersion 和 latestVersion 的值,并根据 cu
无法在 flutter(android 和 IOS)中使用 cloud firestore ...我得到这个异常: E/flutter (10137): [ERROR:flutter/lib/ui/u
我想在我的 flutter 代码中调用一个 kotlin 函数(只是为了使用 consent sdk 设置参数),但是,每次我尝试调用该函数(目前只是测试代码)时,我都会收到错误消息:未处理的异常:M
我收到了 MissingPlugin 错误。我发现了很多关于错误的帖子。但我的情况有点不同。 首先,我的项目在模拟器中运行良好,只有当我在物理 Android 上运行我的发布应用程序时才会出现错误。
我正在尝试通过以下方式创建条形码扫描仪: https://pub.dev/packages/flutter_barcode_scanner/install . 当我运行我的代码时,我得到这个错误: E
final NotificationSettings settings = await messaging.requestPermission(); 调用 firebase 消息传递的 request
我是一名优秀的程序员,十分优秀!